I have a webservice written in C#. When errors occur on the server, I would like to inform the user client side. This works fine by throwing exceptions server side, which is then sent to my error handler client side.
However, I would like to, when I throw the exception, to set a property describing how serious I think the error is at this point. Thus I can decide client side how to display the error:
WebService.Method(some_value, handle_response, handle_error);
function handle_response (response) {
//Do something...
}
function handle_error (error) {
if(error.level === 'Critical') {
//Show critical message.
} else if(error.level === 'Warning') {
//Show warning message.
} else
...
}
}
My solution so far has been to create a custom exception inheriting from System.Exception
.
My webservice returns with a JSON
formatted result.
My problem is how to get my property through to the client side JSON response?