1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-15 09:04:04 +02:00
joplin/packages/app-mobile/plugins/PluginRunner/backgroundPage/utils/reportUnhandledErrors.ts
Henry Heino 55cafb8891
Android: Add support for Markdown editor plugins (#10086)
Co-authored-by: Laurent Cozic <laurent22@users.noreply.github.com>
2024-03-11 15:02:15 +00:00

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;