PDA

View Full Version : [CLOSED] Global exception handler



infonext
May 06, 2013, 11:52 AM
Hi all,

i need a Global exception handler for asp.net errors and ajaxrequest errors (like for example comunication failure).
My handler must intercept errors and visulize a messagebox with details of error and log to database.
But i do not know how to intercept errors from directevents or directmethods (server side if is possible).

Thanks.

RCN
May 06, 2013, 12:36 PM
Please take a look on http://msdn.microsoft.com/en-us/library/w16865z6(v=vs.100).aspx

infonext
May 06, 2013, 2:34 PM
Hi Raphael,

thank for your reponse.
But is possible with this sample to intercept errors on ajaxrequest generated by directevents or directmethods?
I would like to emulate ajaxrequestwarningfailure of ext.net and visualize similar messagebox for both, server side and ajaxrequest errors.

Daniil
May 06, 2013, 4:22 PM
Hi @infonext,

Yes, it should work.

The only thing you might need to set up is

RethrowAjaxExceptions="true"
for a ResourceManager or

rethrowAjaxExceptions="true"in the extnet seciton in a Web.config.

Also it is possible to set up via a Session and an Application objects.

Ext.NET uses try/catch block somewhere. To get those exceptions rethrown, it needs to set up that option to true.

infonext
May 06, 2013, 11:08 PM
Hi Daniil,

thanks for your reponse. I try to get exception on Page_error (all pages inherits from a base page), but if for example a directevents times out and i get a comunication failure message, the Server.GetLastError() is empty.
How i can know the error type in this case?

Vladimir
May 06, 2013, 11:17 PM
I guess that communication failure is not server side error (it can be timeout issue (timeout in javascript code) or problems with net) therefore such error you will not get on the server side

infonext
May 07, 2013, 11:00 AM
Hi Vladimir,

is what i thought (sorry but i aren't very experienced with client side code).
Then if i i wanted to write a global exception handler in javascript for client side errors what strategy should i use?

Thanks.

Daniil
May 07, 2013, 4:44 PM
You can try with window.onerror.
http://stackoverflow.com/questions/951791/javascript-global-error-handling

Also I would try to use a ResourceManager's AjaxRequestException event. It should catch communication failures.

infonext
May 08, 2013, 4:18 PM
Hi Daniil,

many thanks.
With AjaxRequestException on listner of ResourceManager i solved my problem.

You can close the thread.