- 機能/意味
-
Handler function for uncaught exception
- タイプ
-
Systemクラスのプロパティ (読み書き可能)
- 説明
-
Represents a function that handles uncaught exceptions (exceptions passed to Kirikiri core without being caught anywhere).
Specifying null results in the default behavior.
The default behavior is the following:
- Stop delivery of asynchronous events (set System.eventDisabled to true)
- Start outputting log to file (call Debug.logAsError)
- Displays a dialog box that informs you of the error, and indicates the location in the script editor
The handler function takes one argument, which is the exception object.
If no handler function is specified, if the handler function is null, or if the handler function returns false, the default action will be taken.
If the handler function returns true, the above default action will not be taken.
Consider the possibility of asynchronous events occurring while executing the handler function. If the Kirikiri core can handle the asynchronous event, an unexpected exception may occur again while executing the exception handler. In order to avoid this, usually, when performing processing that waits for something in the handler function (when Kirikiri has a chance to process the asynchronous event), stop the occurrence of the asynchronous event.
例:
System.exceptionHandler = function (e)
{
// This function is called when an uncaught exception is caught by the system.
// e is the exception object.
if(e instanceof "ConductorException")
{
// For exceptions thrown by conductors
Debug.logAsError(); // Start writing log to file, etc.
var event_disabled = System.eventDisabled;
System.eventDisabled = true;
// Stop the event once because it is troublesome if an event occurs while displaying the reason of the error
System.inform(e.message);
System.eventDisabled = event_disabled;
// Whether or not to fire the event
return true; // If true is returned, exception processing will not be performed on the core side
}
else
{
return false; // Normal exception handling when returning false
}
};
- 参照
-
System.eventDisabled
Debug.logAsError