更好地处理代码中的错误 [英] Better Handling Of Errors In Code

查看:74
本文介绍了更好地处理代码中的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿伙计我有一个小问题,我正在寻找一个更好的方法来处理。好的,当我的应用程序抛出异常时,我将这些错误记录到数据库中,错误组由一个大的if if语句定义,该语句检查错误消息,即指定文本的堆栈跟踪,并将groupId设置为None,Low,Medium,High或基于找到的文本很关键。 if else语句长达200行,在这个阶段变得有点荒谬。关于如何更好地处理这个的任何想法?干杯们。

解决方案

看看 Log4Net [ ^ ]或 Windows事件日志 [ ^ ]。

Hey guys I have a small issue that I was looking for a better way to handle. Ok when my application throws an exception I log these Errors to the database in Error groups defines by a big long if else statement which checks the errormessage ie the stack trace for the specified text and sets the groupId to None, Low, Medium, High or Critical based on the text found. The if else statement is 200 lines long and is getting a bit ridiculous at this stage. Any ideas on how to handle this better? Cheers guys.

解决方案

Take a look at Log4Net[^] or the Windows Event Log[^].


这篇关于更好地处理代码中的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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