0

I am getting "Uncaught (in promise) t: Error while setting LastConsumedMessageIndex" error message when I am adding a message from Twilio Chat API, after Wraupup chat task. If the agent clicks Complete Task in Twilio Flex just immediately after clicking the Wraupup task button this error message is displaying in the browser console.

Screenshot

I found that this error is generating from the sessionerror.js file that is a part of the Twilio JS SDK. I can not change that file's source code. How can I override this from my custom code?

This is the code I found in sessionerror.js file:

var SessionError = function (_extendableBuiltin2) {
    (0, _inherits3.default)(SessionError, _extendableBuiltin2);

    function SessionError(message, code) {
        (0, _classCallCheck3.default)(this, SessionError);

        var _this = (0, _possibleConstructorReturn3.default)(this, (SessionError.__proto__ || (0, _getPrototypeOf2.default)(SessionError)).call(this));

        _this.name = _this.constructor.name;
        _this.message = message;
        _this.code = code;
        if (Error.captureStackTrace) {
            Error.captureStackTrace(_this, _this.constructor);
        } else {
            _this.stack = new Error().stack;
        }
        return _this;
    }

    return SessionError;
}(_extendableBuiltin(Error));

exports.SessionError = SessionError;

How can I override this?

palaѕн
  • 72,112
  • 17
  • 116
  • 136

1 Answers1

0

I just solved my issue by using unhandledrejection event listener.

Used the following snippets:

window.addEventListener('unhandledrejection', function (event) {
  // ...your code here to handle the unhandled rejection...

  // Prevent the default handling (such as outputting the
  // error to the console)

  event.preventDefault();
});