New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@khgame/err

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@khgame/err

another node.js error library, which supports error code

latest
Source
npmnpm
Version
0.1.1
Version published
Maintainers
1
Created
Source

@khgame/err

another node.js error library, which supports error code

usage

CError

import {CError} from "@khgame/err"
// ...
throw new CError(ERROR_CODE.ValidateError, "Oops") // ERROR_CODE can be enum type of string or number
// ...

CAssert

import {CAssert} from "@khgame/err"

const assert = new CAssert({
  fnLog: console.error // optional, log msg will be send to the logger function if given
})
// ...
CAssert.cThrow(ERROR_CODE.ValidateError, "Oops"); // ERROR_CODE can be enum type of string or number
CAssert.cok(true, ERROR_CODE.ValidateError, () => `you can use this string function to avoid string concat.`);
CAssert.cOk(true, ERROR_CODE.ValidateError, () => `you can also insert an existed error.` );
CAssert.cNotNullAndUndefined(undefined, ERROR_CODE.ValidateError, "there are some more APIs");
CAssert.cStrictEqual(1, 2, ERROR_CODE.ValidateError, "this case will go error");
CAssert.cNotStrictEqual("1", 1, ERROR_CODE.ValidateError, "nothing happend");
// ...

Keywords

error

FAQs

Package last updated on 08 Aug 2019

Did you know?

Socket

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.

Install

Related posts