S
stic
Hi,
I'm in a middle of writing something like 'exception handler wraper'
for a set of different methodes.
The case is that I have ca. 40 methods form web servicem, with
different return values (and types), and with out parmeters. What I
want to do is to support each method call with exception (http 404,
soap exception, and other types of exceptions) and wrap it with try &
catch (a lots of catch ;-)
So I think about:
private object SafeInvoker(delegate) {
try{
retrun invoking delegate
}
catch (A){}
catch (B) {}
catch (C) {}
and so one.
}
but the delegates should be introduced for each of my webservice metod
signature (a lot of combinations.) So I leave it for:
private object SafeInvoker( System.Reflection.MethodInfo mi, object[]
inObjects ) {
try {
return mi.Invoke(this,inObjects);
}
catches..
And this seems to be quite smart solution, but then... I NEED TO handle
[OUT] parameters, and the question is - is MethodInfo.Invoke() able to
handle such a parameters (you know out object[] outObjects in the
SafeInvoker signature, and the mi.Invoke(this, outObjects); make the
"The out parameter 'outObjects' must be assigned to before control
leaves the current method" error.)
Thanks in advance...
If you have another ideas - feel free to bring these ;-)
I'm in a middle of writing something like 'exception handler wraper'
for a set of different methodes.
The case is that I have ca. 40 methods form web servicem, with
different return values (and types), and with out parmeters. What I
want to do is to support each method call with exception (http 404,
soap exception, and other types of exceptions) and wrap it with try &
catch (a lots of catch ;-)
So I think about:
private object SafeInvoker(delegate) {
try{
retrun invoking delegate
}
catch (A){}
catch (B) {}
catch (C) {}
and so one.
}
but the delegates should be introduced for each of my webservice metod
signature (a lot of combinations.) So I leave it for:
private object SafeInvoker( System.Reflection.MethodInfo mi, object[]
inObjects ) {
try {
return mi.Invoke(this,inObjects);
}
catches..
And this seems to be quite smart solution, but then... I NEED TO handle
[OUT] parameters, and the question is - is MethodInfo.Invoke() able to
handle such a parameters (you know out object[] outObjects in the
SafeInvoker signature, and the mi.Invoke(this, outObjects); make the
"The out parameter 'outObjects' must be assigned to before control
leaves the current method" error.)
Thanks in advance...
If you have another ideas - feel free to bring these ;-)