Represents an exception that can be thrown to indicate operation failure along with its cause. You can use this exception type as a custom application or domain validation exception to pass on useful information to the client securely. See the guidance given in the remarks for this purpose.
In order to not reveal sensitive information on production environment via exception, the unhandled exception processors should treat OpException as follows. Call OpResultToStatusCode with Reason and if the status code returned is 500, return a generic error message like “We’re experiencing some difficulties at this time,. Please try again later.”. For other cases, feel free to return the error message. As a developer if you throw OpException, you should make sure that you specify an appropriate OpResult as reason if you want the error message to be returned along with it to the client. You can have application specific custom codes representing OpResult if the existing ones defined in OpResult do not fulfill your requirements. However, if you want to return error message for such codes to the client, you should add such codes to OpResultToHttpStatusCodeMapper because any OpResult instance not in OpResultToHttpStatusCodeMapper will be treated as status 500.
Initializes a new instance of the OpException class.
|reason||ASPSecurityKit.OpResult||The cause of failure.|
|message||System.String||Optional. The error message containing more information about the failure.|
Gets the cause of operation failure.
The cause of operation failure
Gets whether the Message property holds an error message provided explicitly during construction. Only explicitly provided message holds any meaning to return as part of response.
true if the Message property holds an error message provided explicitly during construction; otherwise,