I've just been trying to log exception messages, and discovered that
SqlCeException.Message hides Exception.Message. Why is this? What on
earth is the benefit of the base Exception.Message always returning an
empty string? It's making the logging code much more tortuous -
although admittedly I'm now walking through all the errors and logging
each of them in turn.

--
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Re: SqlCeException.Message - why does it hide Exception.Message? by éric

éric
Tue Feb 24 08:07:39 CST 2004

this will change in sqlce 3.0... in the mean time

internal static void SqlCeExceptionHandling (SqlCeException e)
{
SqlCeErrorCollection errorCollection = e.Errors;
StringBuilder bld = new StringBuilder();
Exception inner = e.InnerException;
if (null != inner)
{
MessageBox.Show("Inner Exception: " + inner.ToString().Replace(
ApplicationSettings.DBPassword, "DBPassword"));
}
foreach (SqlCeError err in errorCollection)
{
bld.Append("\n Error Code: " + err.HResult.ToString("X"));
bld.Append("\n Message : " + err.Message);
bld.Append("\n Minor Err.: " + err.NativeError);
bld.Append("\n Source : " + err.Source);
foreach (int numPar in err.NumericErrorParameters)
{
if (0 != numPar) bld.Append("\n Num. Par. : " + numPar);
}
foreach (string errPar in err.ErrorParameters)
{
if (String.Empty != errPar) bld.Append("\n Err. Par. : " +
errPar);
}
try
{
// I put this here to replace any password strings as the error
tends to show it!!!
MessageBox.Show(bld.ToString().Replace(
ApplicationSettings.DBPassword, "DBPassword"));
bld.Remove(0, bld.Length);
}
catch{}
}
}

"Jon Skeet [C# MVP]" <skeet@pobox.com> wrote in message
news:MPG.1aa539f69d3cb2f498a1fc@msnews.microsoft.com...
> I've just been trying to log exception messages, and discovered that
> SqlCeException.Message hides Exception.Message. Why is this? What on
> earth is the benefit of the base Exception.Message always returning an
> empty string? It's making the logging code much more tortuous -
> although admittedly I'm now walking through all the errors and logging
> each of them in turn.
>
> --
> Jon Skeet - <skeet@pobox.com>
> http://www.pobox.com/~skeet
> If replying to the group, please do not mail me too



Re: SqlCeException.Message - why does it hide Exception.Message? by Jon

Jon
Tue Feb 24 08:16:46 CST 2004

=E9ric <eric@westgen.com> wrote:
> this will change in sqlce 3.0...=20

Goodo :)

> in the mean time

<snip>

Cheers - thanks for the heads-up about the db password, too...

--=20
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too