Socket
Socket
Sign inDemoInstall

code-added-error

Package Overview
Dependencies
0
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    code-added-error

Emulation of basic Error class, with new "code" argument and "file" & "line" static methods


Version published
Weekly downloads
7
increased by600%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

code-added-error

Emulation of basic Error class, with new "code" argument and "file" & "line" static methods

Build status Coverage status Dependency status Dev dependency status Issues Pull requests

Installation

$ npm install code-added-error

Features

Official

Supported

  • Error
  • prototype
  • fileName
  • lineNumber
  • message
  • name
  • stack
  • toString

Supported, non-official

  • toJSON
  • static file
  • static line

Not supported

  • columnNumber
  • toSource

Doc

-- Attributes --

  • name: string plugins' directory path
  • message: string plugins' directory path
  • fileName: string plugins' directory path
  • lineNumber: number plugins' directory path
  • stack: string plugins' directory path

-- Constructor --

  • constructor(message: string, code?: string, fileName?: string, lineNumber?: string)

-- Methods --

  • toString(codeAndMessageOnly?: boolean): string return string-formated error
  • toJSON(codeAndMessageOnly?: boolean): object return JSON-formated error
  • static file(): string return current file
  • static line(): number return current line

Examples

"use strict";

const CodeAddedError = require('code-added-error');

const err = new CodeAddedError("This is a test", "TEST", CodeAddedError.file(), CodeAddedError.line());

console.log(err.name);
console.log(err.message);
console.log(err.toString());
console.log(err.toJSON());

Typescript

"use strict";

import CodeAddedError = require('code-added-error');

const manager = new CodeAddedError("This is a test", "TEST");

console.log(err.name);
console.log(err.message);
console.log(err.toString());
console.log(err.toJSON());

Tests

$ npm run-script tests

License

ISC

Keywords

FAQs

Last updated on 12 Nov 2019

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc