Namespace

DuDebug

DuDebug

Tools for debugging

View Source DuESF.jsxinc, line 963

Members

DuDebugLog | null

# static debugLog

Set this attribute to a DuDebugLog you have created to automatically add some debug infos to the log (like catched errors).

View Source DuESF.jsxinc, line 969

int

# static readonly LogLevel

The log levels
Properties:
Name Type Description
VERBOSE int
DEBUG int
WARNING int
CRITICAL int
FATAL int
NO_DEBUG int

View Source DuESF.jsxinc, line 976

Methods

# static checkVar(variable, argName, argTypeopt, functionNameopt) → {string|bool}

Checks if the given variable has the correct type,
alerts a nice error if not using DuDebug.throwUndefinedError() or DuDebug.throwTypeError().
Parameters:
Name Type Attributes Description
variable any The variable to check
argName string The variable name
argType string <optional>
The expected type name (as return by jstype()). If not provided, checks only if the var is undefined
functionName any <optional>
The name or description of the function throwing the error.

View Source DuESF.jsxinc, line 1208

The (multiline) description for the error if any and DuESF.debug is true, false if there's an error and DuESF.debug is false, true if everything is ok.
string | bool

# static error(error)

This methods shows an alert with an error thrown if DuESF.debug is set to true, and logs it in DuESF.debug.DuDebugLog if it has been set.
The error is actually thrown only if JS Debugging is enabled in the host application, otherwise it is just shown in an alert.
Parameters:
Name Type Description
error Error | string An error thrown and catched

View Source DuESF.jsxinc, line 1001

# static inspect(obj, ownPropertiesopt) → {string}

Inspects a javascript object and outputs all of its attributes
Parameters:
Name Type Attributes Default Description
obj object The object to inspect.
ownProperties boolean <optional>
true Whether to inspect only the own properties of the object.

View Source DuESF.jsxinc, line 1068

The report.
string

# static log(message, levelopt)

Logs a message to DuDebug.DuDebugLog if it has been set.
Parameters:
Name Type Attributes Default Description
message string The message to log
level DuDebug.LogLevel <optional>
DuDebug.LogLevel.DEBUG The level of the message

View Source DuESF.jsxinc, line 991

# static safeRun(callback) → {any}

Runs a method/script safely, i.e. enclosed in a try...catch, and logs any error thrown.
arguments can be added after the first parameter, they will be passed to the callback.
The callback is enclosed in a function to make sure it does not create global variables.
Parameters:
Name Type Description
callback function | string The method to run, or a script as a string

View Source DuESF.jsxinc, line 1025

The return of the callback, null if it fails.
any

# static throwError(message, functionNameopt, erroropt, neverThrowopt) → {string}

Alerts a nice Error description, if DuESF.debug is true, and logs it if there's a log..
Note that it does not actually throws an error.
Parameters:
Name Type Attributes Default Description
message any The message to show
functionName any <optional>
The name or description of the function throwing the error.
error Error <optional>
A JS error.
neverThrow Boolean <optional>
false If true, will prevent actually throwing the error even if the debugger is enabled.

View Source DuESF.jsxinc, line 1161

The (multiline) description for the error
string

# static throwTypeError(variable, varName, varType, functionNameopt) → {string}

Alerts a nice TypeError description, if DuESF.debug is true, and logs it if there's a log.
Note that it does not actually throws an error.
Parameters:
Name Type Attributes Description
variable any The failing argument
varName string The failing argument name
varType string The expected type
functionName string <optional>
The name or description of the function throwing the error.

View Source DuESF.jsxinc, line 1090

The (multiline) description for the error
string

# static throwUndefinedError(varName, functionNameopt) → {string}

Alerts a nice UndefinedError description, if DuESF.debug is true, and logs it if there's a log..
Note that it does not actually throws an error.
Parameters:
Name Type Attributes Description
varName any The name of the arg which should not be undefined
functionName any <optional>
The name or description of the function throwing the error.

View Source DuESF.jsxinc, line 1126

The (multiline) description for the error
string