From 6e38cc13d167504b3bdcf234d94481c1cb8d8b7e Mon Sep 17 00:00:00 2001 From: Savindu Dimal Date: Tue, 18 Jun 2024 15:11:31 +0530 Subject: [PATCH] Add error code and error message Add error code and error message to synapse message context in the fault sequence. --- .../wso2/carbon/websocket/transport/WebSocketClientHandler.java | 2 ++ .../org/wso2/carbon/websocket/transport/WebsocketConstants.java | 2 ++ 2 files changed, 4 insertions(+) diff --git a/components/carbon-transports/websocket/org.wso2.carbon.websocket.transport/src/main/java/org/wso2/carbon/websocket/transport/WebSocketClientHandler.java b/components/carbon-transports/websocket/org.wso2.carbon.websocket.transport/src/main/java/org/wso2/carbon/websocket/transport/WebSocketClientHandler.java index 5d941fbac0a..645c934b120 100644 --- a/components/carbon-transports/websocket/org.wso2.carbon.websocket.transport/src/main/java/org/wso2/carbon/websocket/transport/WebSocketClientHandler.java +++ b/components/carbon-transports/websocket/org.wso2.carbon.websocket.transport/src/main/java/org/wso2/carbon/websocket/transport/WebSocketClientHandler.java @@ -223,6 +223,8 @@ private void invokeFaultSequenceUponError(int statusCode, String reasonText) thr MessageContext synCtx = getSynapseMessageContext(tenantDomain); synCtx.setProperty(InboundWebsocketConstants.WEB_SOCKET_CLOSE_CODE, statusCode); synCtx.setProperty(InboundWebsocketConstants.WEB_SOCKET_REASON_TEXT, reasonText); + synCtx.setProperty(WebsocketConstants.ERROR_CODE, statusCode); + synCtx.setProperty(WebsocketConstants.ERROR_MESSAGE, reasonText); synCtx.setProperty(InboundWebsocketConstants.FAULT_SEQUENCE_INVOKED_ON_WEBSOCKET_CLIENT_HANDLER_ERROR, true); getFaultSequence(synCtx, dispatchErrorSequence).mediate(synCtx); } diff --git a/components/carbon-transports/websocket/org.wso2.carbon.websocket.transport/src/main/java/org/wso2/carbon/websocket/transport/WebsocketConstants.java b/components/carbon-transports/websocket/org.wso2.carbon.websocket.transport/src/main/java/org/wso2/carbon/websocket/transport/WebsocketConstants.java index 5b371edcd51..81631d2fdfa 100644 --- a/components/carbon-transports/websocket/org.wso2.carbon.websocket.transport/src/main/java/org/wso2/carbon/websocket/transport/WebsocketConstants.java +++ b/components/carbon-transports/websocket/org.wso2.carbon.websocket.transport/src/main/java/org/wso2/carbon/websocket/transport/WebsocketConstants.java @@ -80,4 +80,6 @@ public class WebsocketConstants { public static final String WS_CLOSE_DEFAULT_REASON_TEXT = "Websocket server terminated"; public static final int WEBSOCKET_UPSTREAM_ERROR_SC = 1014; + public static final String ERROR_CODE = "ERROR_CODE"; + public static final String ERROR_MESSAGE = "ERROR_MESSAGE"; }