UncaughtException: Difference between revisions
(Created page with "{{ClientsideJsFunction}} {{JSContainer| <syntaxhighlight lang="javascript"> mp.events.add('uncaughtException', (expection) => { //do what you want }); </syntaxhighlight> }} ==See also== {{Player_events_clientside}}") |
No edit summary |
||
| Line 1: | Line 1: | ||
{{ClientsideJsFunction}} | {{ClientsideJsFunction}} | ||
{{JSContainer| | {{JSContainer| | ||
<syntaxhighlight lang=" | {{Parameters}} | ||
mp.events.add( | * '''exception''': Unhandled exception, it is of '''any''' type. | ||
//do | |||
{{Example}} | |||
The example below cancels the default error message box on client unhandled exception/error and prints to the F11 console instead. | |||
<syntaxhighlight lang="JavaScript"> | |||
mp.events.add("uncaughtException", (exception) => { | |||
// Print the message to F11 console or do whatever you need with it | |||
mp.console.logError(`[uncaughtException]: ${exception}`); | |||
// Cancel the event to prevent default error message box | |||
return true; | |||
}); | }); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Latest revision as of 18:39, 3 September 2025
Client-Side Function
JavaScript Syntax
Parameters
- exception: Unhandled exception, it is of any type.
Example
The example below cancels the default error message box on client unhandled exception/error and prints to the F11 console instead.
mp.events.add("uncaughtException", (exception) => {
// Print the message to F11 console or do whatever you need with it
mp.console.logError(`[uncaughtException]: ${exception}`);
// Cancel the event to prevent default error message box
return true;
});
See also
Browser
Checkpoints
Colshapes
Console
Common
- click
- playerChat
- playerCommand
- playerDeath
- playerJoin
- playerQuit
- playerReady
- playerResurrect
- playerRuleTriggered
- playerSpawn
- playerWeaponShot
- addDataHandler
- dummyEntityCreated
- dummyEntityDestroyed
- entityControllerChange
- replayEditorRequest
- pauseMenuItemSelect
- pauseMenuItemChange