From: Arne Vajhøj on
On 04-05-2010 06:26, Tony Johansson wrote:
> Some exception has further information in the Inner Exception property.
> For example the SmtpException has useful information in the InnerException
> that can be used
> Here is an example
> catch (SmtpException ex)
> {
> Exception inner = ex.InnerException;
> MessageBox.Show("Could not send message: " + inner.Message,
> "Problem sending message", MessageBoxButtons.OK,
> MessageBoxIcon.Error);
> }
>
> So my question is why is not the InnerException.Message information put into
> the SmtpException.Message ?

Using the inner exception text as the entire exception text is not good
because the outer exception may actually need to provide some text
as well.

Concatenating the texts is very messy - start considering how to pick
a separator guaranteed not to be present in the texts.

Inner exceptions are typical used as part of encapsulation.

Arne
First  |  Prev  | 
Pages: 1 2
Prev: validate wmf files?
Next: Local service account