S
Simon
Hi everyone,
I'm wondering what you're supposed to do when you call a method that is
required to perform some action but that action subsequently fails. More
specifically, how do you get a custom message back so that you can provide
some useful information to the application user?
It seems we dont have much room for manouever.
Example:
I might have a method called load file which is supposed to return a file
object. Inside this method a problem is detected and the file object can't
be loaded correctly.
What do I do?
Do I return an empty file object and just accept the fact that I cant return
helpful info to the user?
Do I throw an exception even though the file not being loaded isnt really an
exceptional occurence?
Or is there some other approach i can use.
The only way i can see to return context based error messages is to throw an
exception. However, I don't see how you can reconcile the use of exceptions
in non-exceptional circumstances given the general wisdom that says you
should only throw exceptions when something truly unexpected has happened.
Thanks in advance for any advice you can offer.
Kindest Regards
Simon
I'm wondering what you're supposed to do when you call a method that is
required to perform some action but that action subsequently fails. More
specifically, how do you get a custom message back so that you can provide
some useful information to the application user?
It seems we dont have much room for manouever.
Example:
I might have a method called load file which is supposed to return a file
object. Inside this method a problem is detected and the file object can't
be loaded correctly.
What do I do?
Do I return an empty file object and just accept the fact that I cant return
helpful info to the user?
Do I throw an exception even though the file not being loaded isnt really an
exceptional occurence?
Or is there some other approach i can use.
The only way i can see to return context based error messages is to throw an
exception. However, I don't see how you can reconcile the use of exceptions
in non-exceptional circumstances given the general wisdom that says you
should only throw exceptions when something truly unexpected has happened.
Thanks in advance for any advice you can offer.
Kindest Regards
Simon