mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
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;
|