aop - Using Unity 2.0 handle exception -
when use unity 2.0 handle exception, got problem, below:
public class tracebehavior : iinterceptionbehavior { public ienumerable<type> getrequiredinterfaces() { return type.emptytypes; } public imethodreturn invoke(imethodinvocation input, getnextinterceptionbehaviordelegate getnext) { console.writeline(string.format("invoke method:{0}",input.methodbase.tostring())); imethodreturn result = getnext()(input, getnext); if (result.exception == null) { console.writeline("invoke successful!"); } else { console.writeline(string.format("invoke faild, error: {0}", result.exception.message)); result.exception = null; } return result; } public bool willexecute { { return true; } } } i have set result.exception=null (it's meaning have resolved exception , need not throw again.)
however,it throw exception me.
that's not how works. don't set result.exception, instead return input.createmethodreturn(newreturnvalues).
Comments
Post a Comment