The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/packages/apps-engine/deno-runtime/error-handlers.ts

33 lines
835 B

import * as Messenger from './lib/messenger.ts';
export function unhandledRejectionListener(event: PromiseRejectionEvent) {
event.preventDefault();
const { type, reason } = event;
Messenger.sendNotification({
method: 'unhandledRejection',
params: [
{
type,
reason: reason instanceof Error ? reason.message : reason,
timestamp: new Date(),
},
],
});
}
export function unhandledExceptionListener(event: ErrorEvent) {
event.preventDefault();
const { type, message, filename, lineno, colno } = event;
Messenger.sendNotification({
method: 'uncaughtException',
params: [{ type, message, filename, lineno, colno }],
});
}
export default function registerErrorListeners() {
addEventListener('unhandledrejection', unhandledRejectionListener);
addEventListener('error', unhandledExceptionListener);
}