Hi,
Does someone know whether it is a bad practice to create exception
objects through reflection and throw them? I want to use this in order
to dynamically convert from an integer errorCode to an exception (via a
map errorCode -> typeof( Exception))?
Assembly excAssembly = _exceptionType.Assembly;
Object [] args = new Object [ 1] { _errorCode };
Exception e =
(Exception)excAssembly.CreateInstance( _exceptionType.FullName,
false,
BindingFlags.CreateInstance,
null,
args,
null,
null);
throw (e);
Thanks in advance,
Kaloian.