处理错误信息的最佳方式 [英] Best way to handle error messages

查看:123
本文介绍了处理错误信息的最佳方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道什么是你的应用程序处理错误信息的最佳途径。

I'm wondering what is the best way to handle error messages in your application.

目前我工作的一个Web应用程序,所有的错误信息存储在数据库中,我们通过ID得到他们,负是错误的,积极的是成功的消息。

Currently I'm working on a web application and all error messages are stored in the database and we get them by ID, negative is an error ,positive are success messages.

与这个问题是难以维持,并保持短信跟踪。

the problem with that is hard to maintain and keep tracking of text messages.

你有什么办法?

推荐答案

一般来说,我保存在资源文件中的错误消息的文本。如果您使用.NET 2.0或更高版本(Visual Studio 2005或更高版本),资源文件自动编译到强类型类,使得code它访问的消息说,更清晰可读。

Generally speaking, I keep the text of the error messages in resource files. If you're using .NET 2.0 or higher (Visual Studio 2005 or higher), resource files are automatically compiled into strongly-typed classes, making the code which accesses said messages much more clear and readable.

(编辑:在看到另一种意见,其中提到的定位,我觉得荣誉,势必会在这里提到它,以及:.NET资源文件的本地化做了出色的工作,您可以通过相同的获取资源的本地化的文本。 code,只用一些小的调整,以提供CultureInfo的。)

( Having seen another comment which mentions localization, I feel honor-bound to mention it here as well: .NET resource files do an excellent job of localization. You can get the localized text of the resource via the exact same code, with just a few minor tweaks to provide CultureInfo.)

这是说,这听起来像这个问题域的一部分是消息号。这些错误被从数据库中抛出的(比如,作为存储特效或触发器的一部分)?在这种情况下,则数据库存储最有可能的是他们正确的地方,如果只是因为最接近记录他们正在使用的幻数在哪里。

That said, it sounds like a part of this problem domain is a message number. Are these errors being thrown from the database (say, as part of stored procs or triggers)? In that case, then database storage most likely is the right place for them, if only because that documents them most closely to where the "magic numbers" are being used.

这篇关于处理错误信息的最佳方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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