1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-21 09:38:01 +02:00
joplin/packages/app-mobile/components/plugins/backgroundPage/utils/reportUnhandledErrors.ts

15 lines
432 B
TypeScript

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;