[英]Exception Handling in Dynamics CRM SDK
I am currently developing a simple Dynamics CRM Application which allows the user to create new entities records.我目前正在开发一个简单的Dynamics CRM应用程序,它允许用户创建新的实体记录。
So when an error occurred I get the full stack, but I'm wondering if I could get the attribute name responsible for that error.因此,当发生错误时,我会得到完整的堆栈,但我想知道是否可以获得导致该错误的属性名称。
When you want to avoid emitting full stack traces for known CRM platform errors, you can catch errors of type FaultException<OrganizationServiceFault>
and handle them in an appropriate way, like this:当您想避免为已知的 CRM 平台错误发出完整的堆栈跟踪时,您可以捕获
FaultException<OrganizationServiceFault>
类型的错误并以适当的方式处理它们,如下所示:
try
{
service.Create(entity);
}
catch (FaultException<OrganizationServiceFault> ex)
{
switch (ex.Detail.ErrorCode)
{
case 0x80041103: // QueryBuilderNoAttribute
Console.WriteLine(ex.Detail.Message);
// Specific error handling goes here...
return;
default:
throw;
}
}
The platform error codes are documented and can be looked up onMSDN .平台错误代码已记录在案,可以在MSDN上查找。
We can throw an exception and display a message.我们可以抛出异常并显示一条消息。
throw new InvalidPluginExecutionException("Message here...."); throw new InvalidPluginExecutionException("Message here....");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.