diff --git a/native/src/main/java/io/ballerina/stdlib/http/api/nativeimpl/connection/Respond.java b/native/src/main/java/io/ballerina/stdlib/http/api/nativeimpl/connection/Respond.java index 03242c8c95..71e30ceaf8 100644 --- a/native/src/main/java/io/ballerina/stdlib/http/api/nativeimpl/connection/Respond.java +++ b/native/src/main/java/io/ballerina/stdlib/http/api/nativeimpl/connection/Respond.java @@ -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, @@ -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); diff --git a/native/src/main/java/io/ballerina/stdlib/http/transport/message/HttpCarbonMessage.java b/native/src/main/java/io/ballerina/stdlib/http/transport/message/HttpCarbonMessage.java index be989305b6..c2d0e47f48 100644 --- a/native/src/main/java/io/ballerina/stdlib/http/transport/message/HttpCarbonMessage.java +++ b/native/src/main/java/io/ballerina/stdlib/http/transport/message/HttpCarbonMessage.java @@ -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;