Salesforce

How Do I Handle .NET Exceptions? (Magic xpa 4.x)

« Go Back

Information

 
Created BySalesforce Service User
Approval Process StatusPublished
Objective
Description

How Do I Handle .NET Exceptions? (Magic xpa 4.x)

When you work with a .NET object, there can be errors. The object does not handle these errors, but rather passes them to you to decide what to do.

Magic xpa provides an easy way for you to capture the .NET exceptions and decide what to do with them. In an Online program, this would likely mean that you use the Verify operation to give a message to the user. In a Batch program, you would probably log a message to an error log or send an email.

In this simple example, the user is allowed to set an RGB value for the calendar background. RGB values can be anywhere from 0 to 256; but in this program, there is no range set for the variables, and the user is allowed to enter values outside that range.

When the invalid values are sent to .NET, an error condition is raised. Here is how to capture both the fact that there was an error, and the error message.

  1. First, use the DNExceptionOccurred() function to determine if an error occurred. This will execute only if, in fact, there is an error in the last .NET call.

  2. Then, use the DNException(). function to do something with the error. This function returns a .NET exception object, so you can use it directly like a .NET object, and it has several options. DNException().Message, however, will give you a good error message to display to the user.

See also

The Online and Rich Client Samples projects (program NE05 and RNE05)

Reference
Attachment 
Attachment