RE: How to get rid of Bad Coding Habits /// return status
- From: Peter Bromberg [C# MVP] <pbromberg@xxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 25 Apr 2007 17:54:02 -0700
Hehe.
You have to be patient, Sloan.
Explain to them that the caller of this method should wrap their call in a
try / catch block and be prepared to accept the fact that they may get back
an exception.
And just explain why they should not populate some return "string" with the
exception message property and instead, throw the actual exception itself.
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net
"sloan" wrote:
.
Does anyone have any good articles on Exception Handing in DotNet.
As a "get rid of the API mode of knowing if something worked, we're not in
VB6 land anymore Dorothy".
I have a few people at work who keep writing code like below.
public string UpdateEmployee
{
string returnStatus = string.Empty;
try {
Database db = this.GetDatabase();
DbCommand dbCommand = db.GetStoredProcCommand("dbo.[uspAAAAAAAAAAAAAA]");
(dbCommand);
db.ExecuteNonQuery(dbCommand);
}
catch (Exception ex) {
sStatus = "ERROR updating Examiner table: " + ex.Message;
}
return returnStatus;
}
and I need some reference(s) to put a stop to this mess.
At least with API, you checked for = or != to 0.
err.Number
case --020303000003003
msg = "The blah blah blah failed"
Those were good times.
Any good articles are appreciated (esp if the directly tackle this
situation )
- Follow-Ups:
- References:
- Prev by Date: Re: How to get rid of Bad Coding Habits /// return status
- Next by Date: Re: How to get rid of Bad Coding Habits /// return status
- Previous by thread: Re: How to get rid of Bad Coding Habits /// return status
- Next by thread: Re: How to get rid of Bad Coding Habits /// return status
- Index(es):
Relevant Pages
|