Click here to Skip to main content
15,887,267 members
Home / Discussions / C#
   

C#

 
GeneralRe: wher to put try catch block! Pin
Hussam Fattahi28-Mar-10 5:15
Hussam Fattahi28-Mar-10 5:15 
AnswerRe: wher to put try catch block! Pin
Eddy Vluggen28-Mar-10 4:39
professionalEddy Vluggen28-Mar-10 4:39 
GeneralRe: wher to put try catch block! Pin
Hussam Fattahi28-Mar-10 4:56
Hussam Fattahi28-Mar-10 4:56 
AnswerRe: where to put try catch block! Pin
Richard MacCutchan28-Mar-10 4:40
mveRichard MacCutchan28-Mar-10 4:40 
GeneralRe: where to put try catch block! Pin
Hussam Fattahi28-Mar-10 4:52
Hussam Fattahi28-Mar-10 4:52 
GeneralRe: where to put try catch block! Pin
Richard MacCutchan28-Mar-10 4:57
mveRichard MacCutchan28-Mar-10 4:57 
GeneralRe: where to put try catch block! Pin
Hussam Fattahi28-Mar-10 5:04
Hussam Fattahi28-Mar-10 5:04 
GeneralRe: where to put try catch block! Pin
Eddy Vluggen28-Mar-10 5:23
professionalEddy Vluggen28-Mar-10 5:23 
Hussam Fattahi wrote:
the problem is that many exceptions are expected and returning a bool value is not enought to descripe
what error has been caught, so i need to handle in the function that calls save

There is (probably) more than one place where you "save" data. Some things can be handled locally; you might want to handle a "reconnect" to the database and execute the query again. That's the thing that you should catch. All other things should be allowed to pass by.

You'd want two things to happen when an exception occurs; the user needs to know, and someone might be interested in the details of the exception later on.

First things first, the user needs to be informed that something went wrong. That's where the general error-handler comes in, it's a special event that traps all unhandled exceptions. From there you can show a message - without a stacktrace, explaining what went wrong in layman-terms, and explaining what countermeasures can be taken. This way, the user gets a "Disk Full" message, without every programmer checking each method individually and displaying their own windows. It's quite easy to display a helpfull message for the most common ones and to redirect the user to a helpfull webpage.

You'd probably want to log all the exceptions that you didn't handle; these should be treated as bugs. Log4Net could help you out there Smile | :)
I are Troll Suspicious | :suss:

AnswerRe: where to put try catch block! Pin
Keith Barrow28-Mar-10 4:58
professionalKeith Barrow28-Mar-10 4:58 
GeneralRe: where to put try catch block! Pin
Hussam Fattahi28-Mar-10 5:07
Hussam Fattahi28-Mar-10 5:07 
GeneralRe: where to put try catch block! Pin
Kevin McFarlane28-Mar-10 5:46
Kevin McFarlane28-Mar-10 5:46 
AnswerRe: where to put try catch block! Pin
Abhinav S28-Mar-10 5:12
Abhinav S28-Mar-10 5:12 
AnswerRe: where to put try catch block! Pin
PIEBALDconsult28-Mar-10 19:16
mvePIEBALDconsult28-Mar-10 19:16 
QuestionUnable to change registry values Pin
Aseem Sharma27-Mar-10 21:18
Aseem Sharma27-Mar-10 21:18 
AnswerRe: Unable to change registry values Pin
Richard MacCutchan27-Mar-10 21:35
mveRichard MacCutchan27-Mar-10 21:35 
QuestionAbout Entity Framework Pin
mmdullah27-Mar-10 19:15
mmdullah27-Mar-10 19:15 
AnswerRe: About Entity Framework Pin
PSK_27-Mar-10 20:02
PSK_27-Mar-10 20:02 
AnswerRe: About Entity Framework Pin
Not Active28-Mar-10 1:44
mentorNot Active28-Mar-10 1:44 
QuestionMobile Phone Dialer Pin
mmdullah27-Mar-10 19:10
mmdullah27-Mar-10 19:10 
AnswerRe: Mobile Phone Dialer Pin
Mustafa Ismail Mustafa28-Mar-10 0:50
Mustafa Ismail Mustafa28-Mar-10 0:50 
AnswerRe: Mobile Phone Dialer Pin
Eddy Vluggen28-Mar-10 4:27
professionalEddy Vluggen28-Mar-10 4:27 
Questionreduce image size Pin
Jassim Rahma27-Mar-10 12:55
Jassim Rahma27-Mar-10 12:55 
AnswerRe: reduce image size Pin
Eslam Afifi27-Mar-10 13:37
Eslam Afifi27-Mar-10 13:37 
GeneralRe: reduce image size Pin
Jassim Rahma28-Mar-10 11:54
Jassim Rahma28-Mar-10 11:54 
AnswerRe: reduce image size Pin
Luc Pattyn27-Mar-10 15:46
sitebuilderLuc Pattyn27-Mar-10 15: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.