Click here to Skip to main content
15,890,557 members
Home / Discussions / C#
   

C#

 
GeneralRe: Problem with get() method! Pin
Eddy Vluggen20-Jun-14 8:36
professionalEddy Vluggen20-Jun-14 8:36 
GeneralRe: Problem with get() method! Pin
LAPEC20-Jun-14 8:43
LAPEC20-Jun-14 8:43 
GeneralRe: Problem with get() method! Pin
LAPEC20-Jun-14 8:46
LAPEC20-Jun-14 8:46 
GeneralRe: Problem with get() method! Pin
Eddy Vluggen20-Jun-14 9:01
professionalEddy Vluggen20-Jun-14 9:01 
GeneralRe: Problem with get() method! Pin
LAPEC20-Jun-14 9:05
LAPEC20-Jun-14 9:05 
GeneralRe: Problem with get() method! Pin
Eddy Vluggen20-Jun-14 9:23
professionalEddy Vluggen20-Jun-14 9:23 
QuestionException Handling / Response Question Pin
Kevin Marois20-Jun-14 6:45
professionalKevin Marois20-Jun-14 6:45 
GeneralRe: Exception Handling / Response Question Pin
PIEBALDconsult20-Jun-14 7:37
mvePIEBALDconsult20-Jun-14 7:37 
I prefer the general "don't catch it if you're not going to do anything with it" theory. Let it bubble up unmolested until something can actually handle it.

Just above that, is the "catch it, add relevent information to the Data collection, and rethrow it" theory.
As regards database operations, I like to add the SQL statement, parameters, and maybe connection information.
You can also add a timestamp and other information -- too much is better than too little.
Such information should not be presented to the user of course.

In some cases, it makes sense to catch the exception and wrap it in a more descriptive (perhaps custom) exception.
As you probably know, a database problem will just produce a general exception -- which is fairly useless.
When appropriate, you can determine more detail about the exception and throw a more appropriate derived exception -- e.g. DuplicateDataException -- which can help the eventual handler.
I'm of the opinion that such spelunking should be done at the lowest level so the higher levels don't need to know the details of the particular connection in use.
Retain the caught exception as the InnerException, in case the handler does want to know.

Similarly, if logging of the exception is to be performed, it should be done at the highest level that makes sense, not the lowest level. Logging is an application responsibility, not a framework responsibility.

Finally, when catching-and-rethrowing, use throw, not throw ex .
You'll never get very far if all you do is follow instructions.

GeneralRe: Exception Handling / Response Question Pin
Kevin Marois20-Jun-14 7:39
professionalKevin Marois20-Jun-14 7:39 
GeneralRe: Exception Handling / Response Question Pin
PIEBALDconsult20-Jun-14 7:44
mvePIEBALDconsult20-Jun-14 7:44 
GeneralRe: Exception Handling / Response Question Pin
Kevin Marois20-Jun-14 7:52
professionalKevin Marois20-Jun-14 7:52 
GeneralRe: Exception Handling / Response Question Pin
PIEBALDconsult20-Jun-14 8:05
mvePIEBALDconsult20-Jun-14 8:05 
AnswerRe: Exception Handling / Response Question Pin
Eddy Vluggen20-Jun-14 8:05
professionalEddy Vluggen20-Jun-14 8:05 
GeneralRe: Exception Handling / Response Question Pin
Kevin Marois20-Jun-14 8:18
professionalKevin Marois20-Jun-14 8:18 
GeneralRe: Exception Handling / Response Question Pin
Eddy Vluggen20-Jun-14 9:21
professionalEddy Vluggen20-Jun-14 9:21 
GeneralRe: Exception Handling / Response Question Pin
Kevin Marois20-Jun-14 10:22
professionalKevin Marois20-Jun-14 10:22 
GeneralRe: Exception Handling / Response Question Pin
Eddy Vluggen20-Jun-14 11:05
professionalEddy Vluggen20-Jun-14 11:05 
QuestionPass specific object to a method expecting ref object parameter? Pin
arnold_w20-Jun-14 3:24
arnold_w20-Jun-14 3:24 
AnswerRe: Pass specific object to a method expecting ref object parameter? Pin
Richard Deeming20-Jun-14 3:58
mveRichard Deeming20-Jun-14 3:58 
GeneralRe: Pass specific object to a method expecting ref object parameter? Pin
OriginalGriff20-Jun-14 3:59
mveOriginalGriff20-Jun-14 3:59 
GeneralRe: Pass specific object to a method expecting ref object parameter? Pin
Richard Deeming20-Jun-14 4:01
mveRichard Deeming20-Jun-14 4:01 
AnswerRe: Pass specific object to a method expecting ref object parameter? Pin
OriginalGriff20-Jun-14 3:59
mveOriginalGriff20-Jun-14 3:59 
AnswerRe: Pass specific object to a method expecting ref object parameter? Pin
PIEBALDconsult20-Jun-14 7:41
mvePIEBALDconsult20-Jun-14 7:41 
AnswerRe: Pass specific object to a method expecting ref object parameter? Pin
Eddy Vluggen20-Jun-14 8:47
professionalEddy Vluggen20-Jun-14 8:47 
Questionwhen using Stored Procedure called from C# ? Pin
Member 245846719-Jun-14 21:46
Member 245846719-Jun-14 21: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.