mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-27 10:32:58 +02:00
55cafb8891
Co-authored-by: Laurent Cozic <laurent22@users.noreply.github.com>
15 lines
432 B
TypeScript
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;
|