UnhandledRejection
JavaScript
Parameters
- promise: Promise that was rejected and not handled, it is of Promise<any> type.
- error: Error of the promise that was rejected, it is of any type.
Example
The example below cancels the default error message box on client unhandled promise rejection and prints to the F11 console instead.
mp.events.add('unhandledRejection', (promise, error) => {
// Print the message to F11 console or do whatever you need with it
mp.console.logError(`[unhandledRejection]: ${JSON.stringify(promise)} ${error}`);
// Cancel the event to prevent default error message box
return true;
});