代码分析...... [英] Code analisys ...

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

问题描述

....警告我不要使用catch(Exception e)太笼统。

但是如果

尝试如何确定我应该使用什么异常类型部分可能会导致一些异常类型?如何确定

这些行会导致什么样的异常?

XmlTextReader xTr = new XmlTextReader(pFileName);


XmlSerializer xS =新的XmlSerializer(typeof(T));


Catch(Exception)处理所有可能性,我不知道
知道如何选择更详细的例外类型没有

a没有抓住其中一个的风险......

.... is warning me not to use catch(Exception e) as too general.
But how to determine what exception type should I use if
try section may cause a few exception types? How to determine
what kind of exceptions could such lines cause?
XmlTextReader xTr = new XmlTextReader(pFileName);

XmlSerializer xS = new XmlSerializer(typeof(T));

Catch(Exception) handles all of the possibilities and i don''t
know how to choose more detailed exception type without
a risk of not catch one of them ...

推荐答案

嗨Jacek,
如果你有权访问Visual Studio 2005的副本,那么当你在代码视图中的某个函数上鼠标

时它会显示它将抛出的异常

a工具提示,长的方法描述。另外据我所知

是了解os浏览每个

方法的Micorosft文档的唯一方法。


马克。


" Jacek Jurkowski"写道:
Hi Jacek,
if you have access to a copy of Visual Studio 2005 then when you mouse
over a function in the code view it shows the exceptions it will throw inside
a tooltip, long with a description of the method. Otherwise to my knowledge
the only other way to know os to read the Micorosft documentation on each
method.

Mark.

"Jacek Jurkowski" wrote:
....警告我不要使用catch(异常e)太笼统。
但是如果确定我应该使用哪种异常类型试试部分可能会导致一些异常类型?如何确定这些行会导致什么样的异常?
XmlTextReader xTr = new XmlTextReader(pFileName);

XmlSerializer xS = new XmlSerializer(typeof(T)); < catch(Exception)处理所有可能性,我不知道如何选择更详细的异常类型,而不会有抓住其中一个的风险......
.... is warning me not to use catch(Exception e) as too general.
But how to determine what exception type should I use if
try section may cause a few exception types? How to determine
what kind of exceptions could such lines cause?
XmlTextReader xTr = new XmlTextReader(pFileName);

XmlSerializer xS = new XmlSerializer(typeof(T));

Catch(Exception) handles all of the possibilities and i don''t
know how to choose more detailed exception type without
a risk of not catch one of them ...



据我所知(来自这个ng的各个成员),只捕获你想要的

例外/能够处理 - 让其他一切泡沫起来。


Scott

" Jacek Jurkowski" < PC ***** @ priv1.onet.pl>在消息中写道

新闻:%2 **************** @ TK2MSFTNGP15.phx.gbl ...
As I have learned (from various members of this ng), catch only the
exceptions you want/are able to handle-- let everything else bubble up.

Scott
"Jacek Jurkowski" <pc*****@priv1.onet.pl> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
..警告我不要使用catch(异常e)过于笼统。
但是如果确定应该使用哪种异常类型可能会导致一些异常类型?如何确定这些行会导致什么样的异常?
XmlTextReader xTr = new XmlTextReader(pFileName);

XmlSerializer xS = new XmlSerializer(typeof(T)); < catch(Exception)处理所有可能性,我不知道如何选择更详细的异常类型,而不会有抓住其中一个的风险......
... is warning me not to use catch(Exception e) as too general.
But how to determine what exception type should I use if
try section may cause a few exception types? How to determine
what kind of exceptions could such lines cause?
XmlTextReader xTr = new XmlTextReader(pFileName);

XmlSerializer xS = new XmlSerializer(typeof(T));

Catch(Exception) handles all of the possibilities and i don''t
know how to choose more detailed exception type without
a risk of not catch one of them ...



我看到异常可能导致SMTP上的Send方法。

它是整个列表!我不会抓住每个可能的异常类型

只是因为Exception is general看起来像Code Analisys

发疯了!
I saw the exceptions may cause a Send method on SMTP.
It''s whole list! I will not catch every possible exception type
only because "Exception is to general" Looks like Code Analisys
gone mad!


这篇关于代码分析......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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