Click here to Skip to main content
15,919,479 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more: , +
I have a website where I want to pass an error code to the user so that QA can look back at the error and figure out what happened. I want to do this without displaying specific error details like the exception message or stack trace to the end user. I wrote the below method that sits inside of the top-level master page for the site and I'm wondering what the best way to call it is if any exception is raised in the application.

The only way to do so that I have thought up of so far is too create try catch blocks in every method in the project but I don't really want to do that.

public void ExceptionHandler(Exception e)
            string s = Guid.NewGuid().ToString();

                throw new Exception(s, e);
            catch (Exception ex)
                throw ex;
                divException.InnerHtml = "An exception has occured, please contact QA for more info.\n Error Code: " + s;

And if, I'm doing this the completely wrong way from the first place feel free to suggest other solutions.

1 solution

See these articles for some ideas:

Click me![^]

and me![^]
Share this answer
Kyle Gottfried 15-Aug-13 13:22pm    
Thanks for helping out. I've read the tutorial but I'm still having some issues.
Richard C Bishop 15-Aug-13 13:59pm    
You are welcome. Excellent job extracting info from those sources and attempting it yourself!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900