dreamworkAPI
Ctrl K
GitHub
libraryDocs / dreamwork / exceptions

dreamwork.exceptions

librarysource

Functions

dreamwork.exceptions.callCalls the function in protected mode, errors are displayed and do not propagate.
dreamwork.exceptions.catchxpcall message handler for errors that are going to be rethrown.
dreamwork.exceptions.handlerxpcall message handler that converts the error into an Error, displays it and returns it.

#dreamwork.exceptions.call

sharedmenusource
function dreamwork.exceptions.call(fn: function, ...: any): boolean, any

Calls the function in protected mode, errors are displayed and do not propagate.

Same as xpcall( fn, dreamwork.exceptions.handler, ... ), use it for callbacks whose errors must not break the caller (hooks, timers, network receivers, ...).

Parameters
NameTypeDescription
fnfunctionThe function to call.
...anyThe arguments to pass to the function.
Returns
TypeNameDescription
booleansuccesstrue if the function did not raise an error.
any...The function results on success, the displayed Error otherwise.

#dreamwork.exceptions.catch

sharedmenunodiscardsource
function dreamwork.exceptions.catch(error_value: any): Error | any

xpcall message handler for errors that are going to be rethrown.

Works like toError, but values that are neither errors nor strings (signals like ACTION_CANCEL) are returned as is, so rethrowing them keeps their identity, the same way error throws them.

Parameters
NameTypeDescription
error_valueanyThe error value to handle.
Returns
TypeNameDescription
Error | anyerror_object

#dreamwork.exceptions.handler

sharedmenusource
function dreamwork.exceptions.handler(error_value: any): Error

xpcall message handler that converts the error into an Error, displays it and returns it.

Parameters
NameTypeDescription
error_valueanyThe error value to handle.
Returns
TypeNameDescription
Errorerror_object
Generated from the dreamwork meta branch.