diff --git a/server/src/stateManagement.mjs b/server/src/stateManagement.mjs index be2ee7b..85c03b7 100644 --- a/server/src/stateManagement.mjs +++ b/server/src/stateManagement.mjs @@ -285,6 +285,13 @@ async function handleDynamicResponseValues(userId, methodName, params, ws, resp) // After the result function was called, we're realizing what it returned isn't valid! logInvalidMethodError(methodName, resultErrors, resp); } + if (typeof result === "object" && result.hasOwnProperty("error")) { + resp = result; + } else if (typeof result === "object" && result.hasOwnProperty("code")) { + resp = { + error: result, + }; + } } catch ( ex ) { if ( ex instanceof commonErrors.FireboltError ) { // Looks like the function threw a FireboltError, which means we want to mock an error, not a result