1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-30 10:36:35 +02:00
joplin/packages/app-mobile/components/plugins/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;