Error : Error management

更新时间:
2024-03-04
下载文档

Error : Error management

JSRE currently enhances JavaScript standard Error objects.

 User ModePrivilege Mode
Error
Error.stackTraceLimit
ExtError
error.stack
error.name
error.message
error.code
error.errno
error.info

new Error(message)

  • message {String} Error message.
  • Returns: {Error} A error object.

Create an Error object. Error objects supported by JSRE include: Error, EvalError, RangeError, ReferenceError, SyntaxError, TypeError, URIError.

Example

throw new Error('Test error!');
throw new TypeError('Test type error!');

Error.stackTraceLimit

  • {Integer}

The call stack depth saved when the Error object was created. The default value is 32. This property is write-only. 0 means unlimited depth.

new ExtError(message, code[, errno[, info]])

  • message {String} Error message.
  • code {String} Error code.
  • errno {Integer} Can save operating system kernel error numbers.
  • info {Object} Error extension information.
  • Returns: {Error} A error object.

Create an extended error object. error.name is 'Error'.

Example

try {
  throw new ExtError('MSG', 'ERR_TEST', sys.errno());
} catch (error) {
  console.log(error.message, error.code, error.errno);
}

error.stack

  • {Array}

Call stack record when creating Error object.

Example

var error = new TypeError('aaaa');
console.log(error.stack);

error.name

  • {String}

Get error type. It may contain the following:

  • 'Error' Common type error.
  • 'EvalError' eval() function error.
  • 'RangeError' Value is outside the specified range.
  • 'ReferenceError' Illegal reference.
  • 'SyntaxError' Syntax error.
  • 'TypeError' Type error.
  • 'URIError' Error from encodeURI() function.

error.message

  • {String}

Error message saved when creating the error object.

error.code

  • {String}

Error code saved when creating the extended error object.

error.errno

  • {Integer}

Operating system error number saved when creating the extended error object. This is an optional property of the ExtError object.

error.info

  • {Object}

Additional information saved when creating the extended error object. This is an optional property of the ExtError object.

文档内容是否对您有所帮助?
有帮助
没帮助