Click here to Skip to main content
15,886,919 members
Home / Discussions / C#
   

C#

 
AnswerRe: Exception Handling Pin
BobJanova16-Nov-12 3:41
BobJanova16-Nov-12 3:41 
GeneralRe: Exception Handling Pin
Phanindra26116-Nov-12 8:03
Phanindra26116-Nov-12 8:03 
AnswerRe: Exception Handling Pin
Clifford Nelson16-Nov-12 9:49
Clifford Nelson16-Nov-12 9:49 
GeneralRe: Exception Handling Pin
Dave Kreskowiak16-Nov-12 11:49
mveDave Kreskowiak16-Nov-12 11:49 
AnswerRe: Exception Handling Pin
Orjan Westin16-Nov-12 4:37
professionalOrjan Westin16-Nov-12 4:37 
AnswerRe: Exception Handling Pin
SledgeHammer0116-Nov-12 9:55
SledgeHammer0116-Nov-12 9:55 
JokeRe: Exception Handling Pin
Mycroft Holmes16-Nov-12 15:42
professionalMycroft Holmes16-Nov-12 15:42 
AnswerRe: Exception Handling Pin
jschell17-Nov-12 6:20
jschell17-Nov-12 6:20 
Phanindra261 wrote:
When creating big applications(even medium apps) there are so many different kinds of exceptions that can come?

How to go about handling them?


Ideally by the following
1. Anticipate expected conditions that can result in errors. These of course vary by the area of the application/enterprise in which they appear.
2. Consider what the application/enterprise should do when those occur. This includes how or even if it should be logged.
3. Implement the code based on 1/2
4. Unit test the code of 3, including the exception generation
5. Besides the above boundary layers should ALWAYS assume that unexpected errors will occur. Those exceptions should be caught and logged once (not every layer.) Each layer must determine what the result is when an unexpected exception occurs and what the layer (or specific parts of the layer) do when an unexpected exception occurs.

As an example...

A database layer should always expect that communication errors will occur. There are various ways of dealing with this (which do not matter for this discussion) but they should still be expected. Even a clustered database solution can experience communication failure. Whether this is logged depends on how it is handled but even if the database layer is returning it as a result failure is should not log a stack trace, but just log it as a single error (db comm error.)

A database layer should not normally expect a SQL syntax error. That is something that should normally only occur during development or QA. So if it occurs one must log it. The database layer can handle this as a failed result.
QuestionManual Coding vs Code Generation Pin
Phanindra26116-Nov-12 0:22
Phanindra26116-Nov-12 0:22 
AnswerRe: Manual Coding vs Code Generation Pin
DaveyM6916-Nov-12 0:46
professionalDaveyM6916-Nov-12 0:46 
GeneralRe: Manual Coding vs Code Generation Pin
n.podbielski16-Nov-12 1:06
n.podbielski16-Nov-12 1:06 
GeneralRe: Manual Coding vs Code Generation Pin
DaveyM6916-Nov-12 2:37
professionalDaveyM6916-Nov-12 2:37 
GeneralRe: Manual Coding vs Code Generation Pin
n.podbielski16-Nov-12 2:47
n.podbielski16-Nov-12 2:47 
GeneralRe: Manual Coding vs Code Generation Pin
BobJanova16-Nov-12 3:22
BobJanova16-Nov-12 3:22 
GeneralRe: Manual Coding vs Code Generation Pin
n.podbielski16-Nov-12 3:43
n.podbielski16-Nov-12 3:43 
AnswerRe: Manual Coding vs Code Generation Pin
Orjan Westin16-Nov-12 2:17
professionalOrjan Westin16-Nov-12 2:17 
GeneralRe: Manual Coding vs Code Generation Pin
Phanindra26116-Nov-12 3:09
Phanindra26116-Nov-12 3:09 
GeneralRe: Manual Coding vs Code Generation Pin
Orjan Westin16-Nov-12 3:25
professionalOrjan Westin16-Nov-12 3:25 
AnswerRe: Manual Coding vs Code Generation Pin
BobJanova16-Nov-12 3:25
BobJanova16-Nov-12 3:25 
AnswerRe: Manual Coding vs Code Generation Pin
fjdiewornncalwe16-Nov-12 7:11
professionalfjdiewornncalwe16-Nov-12 7:11 
GeneralRe: Manual Coding vs Code Generation Pin
Phanindra26116-Nov-12 7:56
Phanindra26116-Nov-12 7:56 
GeneralRe: Manual Coding vs Code Generation Pin
fjdiewornncalwe16-Nov-12 8:26
professionalfjdiewornncalwe16-Nov-12 8:26 
AnswerRe: Manual Coding vs Code Generation Pin
Mycroft Holmes16-Nov-12 15:37
professionalMycroft Holmes16-Nov-12 15:37 
GeneralRe: Manual Coding vs Code Generation Pin
PIEBALDconsult21-Nov-12 17:51
mvePIEBALDconsult21-Nov-12 17:51 
GeneralRe: Manual Coding vs Code Generation Pin
Mycroft Holmes21-Nov-12 18:46
professionalMycroft Holmes21-Nov-12 18:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.