Jitex
Jitex copied to clipboard
Handling exception on intercept method
https://github.com/Hitmasu/Jitex/issues/85#issuecomment-1649120739
When Jitex intercepts a method, we don't add any exception handling. Therefore, if the method throws an exception, the Interceptor will be interrupted without a return or calling ReleaseTask.
Eg.:
public int IsEven(int number) {
//Jitex interceptor implementation...
if (context.ProceedCall) {
if (number == 0)
throw new InvalidOperationException();
result = number % 0 == 1;
}
callManager.ReleaseTask();
}
Should be:
public int IsEven(int number) {
//Jitex interceptor implementation...
if (context.ProceedCall) {
try {
if (number == 0)
throw new InvalidOperationException();
result = number % 0 == 1;
} catch (Exception ex) {
context.SetException(ex);
}
}
if (context.Exception != null)
throw context.Exception;
callManager.ReleaseTask();
}