You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: powerapps-docs/developer/common-data-service/webapi/compose-http-requests-handle-errors.md
+75-1Lines changed: 75 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -180,7 +180,81 @@ Details about errors are included as JSON in the response. Errors will be in thi
180
180
181
181
Some errors can include additional details using *annotations*. When a request includes the `Prefer: odata.include-annotations="*"` header, the response will include all the annotations which will include additional details about errors and a URL that can be used to be directed to any specific guidance for the error.
182
182
183
-
Some of these details can be set by developers writing plug-ins. For example, Let’s say you have a plug-in that throws an error using the <xref:Microsoft.Xrm.Sdk.InvalidPluginExecutionException.#ctor(Microsoft.Xrm.Sdk.OperationStatus,System.Int32,System.String)> constructor. This allows you to pass an OperationStatus, a custom integer error code, and an error message.
183
+
Some of these details can be set by developers writing plug-ins. For example, Let’s say you have a plug-in that throws an error using the [InvalidPluginExecutionException(OperationStatus, Int32, String)](/dotnet/api/microsoft.xrm.sdk.invalidpluginexecutionexception.-ctor#Microsoft_Xrm_Sdk_InvalidPluginExecutionException__ctor_Microsoft_Xrm_Sdk_OperationStatus_System_Int32_System_String_) constructor. This allows you to pass an OperationStatus value, a custom integer error code, and an error message.
184
+
185
+
A simple plug-in might look like this:
186
+
187
+
```csharp
188
+
namespace MyNamespace
189
+
{
190
+
public class MyClass : IPlugin
191
+
{
192
+
public void Execute(IServiceProvider serviceProvider)
throw new InvalidPluginExecutionException(OperationStatus.Canceled, 12345, "Example Error Message.");
204
+
}
205
+
catch (InvalidPluginExecutionException ex)
206
+
{
207
+
tracingService.Trace("StackTrace:");
208
+
tracingService.Trace(ex.StackTrace);
209
+
throw ex;
210
+
}
211
+
}
212
+
}
213
+
}
214
+
```
215
+
216
+
When this plug-in is registered on the create of an account entity, and the request to create an account includes the `odata.include-annotations="*"` preference, the Request and response will look like the following:
217
+
218
+
**Request**
219
+
220
+
```http
221
+
POST https://yourorg.api.crm.dynamics.com/api/data/v9.1/accounts HTTP/1.1
|`@Microsoft.PowerApps.CDS.ErrorDetails.OperationStatus`|`1`|The value of the <xref:Microsoft.Xrm.Sdk.OperationStatus> set by the [InvalidPluginExecutionException(OperationStatus, Int32, String)](/dotnet/api/microsoft.xrm.sdk.invalidpluginexecutionexception.-ctor#Microsoft_Xrm_Sdk_InvalidPluginExecutionException__ctor_Microsoft_Xrm_Sdk_OperationStatus_System_Int32_System_String_) constructor.|
253
+
|`@Microsoft.PowerApps.CDS.ErrorDetails.SubErrorCode`|`12345`|The value of the `SubErrorCode` set by the [InvalidPluginExecutionException(OperationStatus, Int32, String)](/dotnet/api/microsoft.xrm.sdk.invalidpluginexecutionexception.-ctor#Microsoft_Xrm_Sdk_InvalidPluginExecutionException__ctor_Microsoft_Xrm_Sdk_OperationStatus_System_Int32_System_String_) constructor.|
254
+
|`@Microsoft.PowerApps.CDS.HelpLink`|`http://go.microsoft.com/fwlink/?LinkID=398563&error=Microsoft.Crm.CrmException%3a80040265&client=platform`|A URL that contains information about the error which *may* re-direct you to guidance about how to address the error.|
255
+
|`@Microsoft.PowerApps.CDS.TraceText`|`[MyNamespace: MyNamespace.MyClass ]`<br/>`[52e2dbb9-85d3-ea11-a812-000d3a122b89: MyNamespace.MyClass :Create of account]`<br/><br/>`Entering MyClass plug-in.`<br/>`StackTrace:`<br/>` at MyNamespace.MyClass.Execute(IServiceProvider serviceProvider)`||
256
+
|`@Microsoft.PowerApps.CDS.InnerError.Message`|`Example Error Message.`|Content written to the Plug-in trace log using the [ITracingService.Trace(String, Object[]) Method](/dotnet/api/microsoft.xrm.sdk.itracingservice.trace). This includes the stacktrace for the plugin because the plug-in author logged it.|
0 commit comments