System.exceptionHandler

Function/Meaning
Handler function for uncaught exception
Type
System Class Properties
Explanation

Represents a function that handles uncaught exceptions (exceptions passed to Kirikiri itself without being caught anywhere).
Specifying null is the default behavior.
The default behavior is to stop the delivery of asynchronous events (set System.eventDisabled to true) and start outputting logs to a file (call Debug.logAsError) to display a dialog box informing you of the error and in the script editor. It shows the place.
The handler function takes one argument, which becomes the exception object.
If no handler function is specified, the handler function is null, or the handler function returns false, the default behavior is taken.
If the handler function returns true, the above default behavior will not occur.
Consider the possibility of an asynchronous event occurring while executing a handler function.
If Kirikiri itself can handle asynchronous events, an unexpected exception may occur again while executing the exception handler.
To avoid this, normally, if you want to wait for something in the handler function (when Kirikiri has a chance to handle the asynchronous event), stop the occurrence of the asynchronous event.
Example:


System.exceptionHandler = function (e){
// This function is called when an exception that is not caught anywhere is caught on the system side. e is an exception object.
if(e instanceof "ConductorException"){
// In the case of a conductor thrown exception
Debug.logAsError();
// Start of writing log to file, etc.
var event_disabled = System.eventDisabled;System.eventDisabled = true;
// It is troublesome if an event occurs while displaying the reason for the error, so stop the event occurrence once
System.inform(e.message);
System.eventDisabled = event_disabled;
// Whether to raise an event or not to the original state
return true;
// If true is returned, exception handling will not be performed on the main unit side.
}else{
return false;
// Normal exception handling if false is returned
}
};

Reference
System.eventDisabled
Debug.logAsError