Skip to content

Commit

Permalink
Log unhandled internal errors at native level
Browse files Browse the repository at this point in the history
  • Loading branch information
TharmiganK committed Jan 29, 2024
1 parent 6b454b1 commit b94f36f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,11 @@ public static boolean invokeResponseInterceptor(Environment env, HttpCarbonMessa
throw new BallerinaConnectorException("no Interceptor Service found to handle the response");
}

if (interceptorServiceIndex == 0 && inboundMessage.isInterceptorInternalError()) {
BError bError = (BError) inboundMessage.getProperty(HttpConstants.INTERCEPTOR_SERVICE_ERROR);
bError.printStackTrace();
}

interceptorServiceIndex -= 1;
inboundMessage.setProperty(HttpConstants.RESPONSE_INTERCEPTOR_INDEX, interceptorServiceIndex);
startInterceptResponseMethod(inboundMessage, outboundResponseObj, callerObj, service, env,
Expand All @@ -215,6 +220,7 @@ public static boolean invokeResponseInterceptor(Environment env, HttpCarbonMessa
throw HttpUtil.createHttpError(e.getMessage(), HttpErrorType.GENERIC_LISTENER_ERROR);
}
}
// Handling error panics
if (inboundMessage.isInterceptorError()) {
HttpResponseInterceptorUnitCallback callback = new HttpResponseInterceptorUnitCallback(inboundMessage,
callerObj, outboundResponseObj, env, dataContext, null, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,11 @@ public boolean isInterceptorError() {
return this.getProperty(HttpConstants.INTERCEPTOR_SERVICE_ERROR) != null;
}

public boolean isInterceptorInternalError() {
return this.getProperty(HttpConstants.INTERNAL_ERROR) != null &&
this.getProperty(HttpConstants.INTERCEPTOR_SERVICE_ERROR) != null;
}

public String getRequestInterceptorServiceState() {
if (isInterceptorError()) {
return HttpConstants.REQUEST_ERROR_INTERCEPTOR;
Expand Down

0 comments on commit b94f36f

Please sign in to comment.