Model State Errors (or) Custom exceptions of a certain type
I have an application ASP.NET MVC with JQUERY application that throws 4
kinds of errors
Unhanded exceptions (400, 403,500 503 etc) - throw generic exceptions
NOT SEVERE Expected exceptions/ errors (custom exceptions)- e.g. Trying to
look for a contact that does not exist in the system - The system needs to
throw "Contact_not_found_exception" and show this to the user as "Contact
does not exist in the system" . It does not stop the user from doing
anything else but its just to alert the user
VERY SEVERE Expected exceptions/ errors (custom exceptions)- e.g. Trying
to create a contact that already exist in the system - The system needs to
throw "Contact_duplicated_exception" and show this to the user as "Contact
was previously created. Could not proceed as name should be unique"
Model state errors (UI). Errors that I add to modelstate to showup on the
page using @Html.ValidationSummary(true)
Client validation errors which are caught on the front end and application
errors are caught in global.asax
I am looking for a good way to catch errors/exceptions of type 2 and 3 and
return it back to AJAX() Calls with a certain severity type "Critical" vs
"Warning".
I have been following the link for Handling validation errors on Ajax
calls in Asp.net MVC
http://erraticdev.blogspot.com/2010/11/handling-validation-errors-on-ajax.html
I cannot generalize and add all the model state errors as
ModelStateException. As most of these errors/exceptions are of a certain
severity type and my front end (JQUERY) should read this type of error and
do different actions.
How do I create a dictionary of custom exception , severity type ?
How do I throw these and add it to model state error.
How do I catch these globally using Custom Handle Erro Arrtibute and
IExceptionFilter
Thanks, Hephs
No comments:
Post a Comment