javascript - 解决 Twilio “Uncaught (in promise) t: Error while setting LastConsumedMessageIndex”错误消息
问题描述
在 Wraupup 聊天任务之后,当我从 Twilio Chat API 添加消息时,我收到“Uncaught (in promise) t: Error while setting LastConsumedMessageIndex”错误消息。如果代理在单击 Wraupup 任务按钮后立即单击 Twilio Flex 中的完成任务,则此错误消息将显示在浏览器控制台中。
我发现这个错误是从作为 Twilio JS SDK 一部分的 sessionerror.js 文件生成的。我无法更改该文件的源代码。如何从我的自定义代码中覆盖它?
这是我在 sessionerror.js 文件中找到的代码:
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;
我怎样才能覆盖这个?
解决方案
我刚刚通过使用unhandledrejection事件侦听器解决了我的问题。
使用了以下片段:
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();
});
推荐阅读
- python - 麻木 | 如何获取特定形式的图像数组
- ruby-on-rails - Gem::Ext::BuildError: 错误: 无法构建 gem 原生扩展。对于 SQLite3
- python - numpy frombuffer() 和 tostring() - 从 csv 读取
- scala - 使用 Spark Connector for CosmosDB 时的 Jackson 版本不兼容
- terraform - Terraform 自定义信任库
- python - 带有 method='linear' 和 'nearest' 的 Pandas.DataFrame interpolate() 为尾随 NaN 返回不一致的结果
- java - 为执行器端点定义不同上下文的正确/最干净的方法是什么?
- html - 用图案填充 SVG 路径而不拉伸
- asp.net-core - 在 Aspnet Core 2.1 Azure App Service 中长时间运行导出到 excel 作业
- data-structures - 在球形树上吠叫还是去别处看?