
Security News
TypeScript is Porting Its Compiler to Go for 10x Faster Builds
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
abstract-error
Advanced tools
abstract error class with error code supports to create error class quickly
abstract error class with error code supports to create error class quickly.
All Errors are derived from the AbstractError.
import { AbstractError, createErrorClass } from 'abstract-error'
message
: the error message.code
: the error code.createErrorClass(aType: string, aErrorCode: number, ParentErrorClass=AbstractError): typeof AbstractError
import { CommonError } from 'abstract-error'
CommonError
derived from the AbstractError
. All Common Errors are derived from the CommonError
.
The CommonError
use the number as error code.
createErrorClass(aType: string, aErrorCode?: number, ParentErrorClass=CommonError): typeof CommonError
the error codes:
use the createErrorClass
function can extend the AbstractError.
createErrorClass(typeName, errorCode?: number|string, parentErrorClass?: typeof AbstractError): typeof AbstractError
arguments
typeName
(string): the error type name, the first character must be upper case.errorCode
: (number|string): the optional error code, it should be not equal 0 if it's a number.parentErrorClass
: (class): the optional parent error class. defaults to AbstractError
.return
import {CommonError, Errors, createCommonErrorClass} from 'abstract-error';
const NotFoundError = Errors.NotFoundError
const AlreadyReadError = createCommonErrorClass('AlreadyRead', 10000)
const err = new AlreadyReadError('already read over error.')
assert.ok(CommonError.isAlreadyRead(err))
assert.ok(AlreadyReadError.isAlreadyRead(err))
assert.ok(err.alreadyRead())
assert.equal(err.message, 'already read over error.')
assert.equal(err.code, 10000)
FAQs
abstract error class with error code supports to create error class quickly
The npm package abstract-error receives a total of 11 weekly downloads. As such, abstract-error popularity was classified as not popular.
We found that abstract-error demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.