Home

Awesome

AbtractError Build Status npm downloads license

abstract error class with error code supports to create error class quickly.

AbstractError Classes

AbstractError

All Errors are derived from the AbstractError.

the error codes:

Other Error Classes:

Extends the AbstractError

use the createError function can extend the AbstractError.

createError(typeName, errorCode[, parentErrorClass])

arguments

return

Usage



var Errors = require("abstract-error/Error")
var AbstractError = Errors.AbstractError
var createError = Errors.createError


var AlreadyReadError = createError('AlreadyRead', 10000)

var err = new AlreadyReadError("already read over error.")

assert.ok(AbstractError.isAlreadyRead(err))
assert.ok(AlreadyReadError.isAlreadyRead(err))
assert.ok(err.alreadyRead())
assert.equal(err.message, "already read over error.")
assert.equal(err.code, 10000)