0.1.5 • Published 4 years ago

code-added-error v0.1.5

Weekly downloads
2
License
ISC
Repository
github
Last release
4 years ago

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

0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago