处理母版页设置中的异常的最佳方法 [英] The best way to handle exceptions in a Masterpage setup

查看:113
本文介绍了处理母版页设置中的异常的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网站,我想将错误代码传递给用户,以便QA可以回顾错误并弄清楚发生了什么。我想这样做而不向最终用户显示特定错误详细信息,例如异常消息或堆栈跟踪。我编写了以下方法,该方法位于网站的顶级母版页内,我想知道如果在应用程序中引发任何异常,最好的方法是什么。



到目前为止我想到的唯一方法就是在项目的每个方法中创建try catch块,但我真的不想这样做。



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();

            try
            {
                throw new Exception(s, e);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                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.

推荐答案

请参阅这些文章以获取一些想法:



点击我! [ ^ ]



和我! [ ^ ]
See these articles for some ideas:

Click me![^]

and me![^]


这篇关于处理母版页设置中的异常的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆