Exception handling retrieving param values

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi,

Does anyone know how to get parameter values from an
exception using reflection?

i.e

public void GoGadget(string a, string b)
{
return (2/0);
}

try
{
GoGadget(1,4)
}
catch(Exception ex)
{
MessageBox(getExceptionParam(ex));
}

The above example would return me a=1, b=4

John
 
John said:
Hi,

Does anyone know how to get parameter values from an
exception using reflection?

Parameter values are not part of the exception, so you can't get them via
reflection.
 
john said:
Hi John,

Do you know another way of getting them?

No, I don't. The debugger can sometimes get them, but I don't know how.

For explicitly-thrown exceptions, people usually pass whatever they need in
the exception itself.
 
Back
Top