Catch-all error handling on application level?

前端 未结 5 1874
面向向阳花
面向向阳花 2021-01-19 04:58

I have a WPF form with a couple of buttons, and for each button I have error handling code:

try {bla bla} 
catch(Exception e){
  more bla
}

5条回答
  •  孤城傲影
    2021-01-19 05:36

    Add this to you Global.asax:

    protected void Application_Error(object sender, EventArgs e) {
        Exception currentException = Server.GetLastError();
    
        // your handling code goes here ...
    
        Server.ClearError();
    }
    

提交回复
热议问题