1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00
joplin/packages/app-mobile/plugins/PluginRunner/backgroundPage/utils/reportUnhandledErrors.ts

15 lines
432 B
TypeScript
Raw Normal View History

type OnErrorCallback = (errorMessage: string)=> void;
const reportUnhandledErrors = (onError: OnErrorCallback) => {
window.addEventListener('unhandledrejection', (event) => {
onError(`Unhandled promise rejection: ${event.reason}. Promise: ${event.promise}.`);
});
window.addEventListener('error', (event) => {
onError(`Error: ${event.message}. ${event.error?.stack ?? ''}`);
});
};
export default reportUnhandledErrors;