Simon,
You could always return an error code, an integer (or value from an
enumeration) indicating what the status is. This would allow you to
indicate a good number of situations, which should suit your needs.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
mvp@spam.guard.caspershouse.com
"Simon" <sh856531@microsofts_free_email_service.com> wrote in message
news:eg2hVwT2EHA.3468@TK2MSFTNGP14.phx.gbl...[color=blue]
> 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
>
>
>
>[/color]