0.1.2 • Published 5 years ago

terrs v0.1.2

Weekly downloads
1
License
MIT
Repository
-
Last release
5 years ago

terrs

A JavaScript errors library

Installation

$ npm i terrs

Usage

const {TError} = require("terrs");

const error =  TError.create('The main error', new Error('The nested error'));

console.log(error);
/*  => 
    1 |"use strict";
    2 |Object.defineProperty(exports, "__esModule", { value: true });
    3 |class TError extends Error {
    4 |    static create(message, cause) {
 >  5 |        return new TError(message, cause);
    6 |    }
    7 |    constructor(message, cause) {
    8 |        if (message instanceof Error) {
    9 |            cause = message;
   10 |            message = "";

   at Function.create ([...]/terrs/lib/terror.js:5:16)
   at Object.<anonymous> ([...]/terrs/examples/example.js:3:22)
   at Module._compile (internal/modules/cjs/loader.js:689:30)
   at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
   at Module.load (internal/modules/cjs/loader.js:599:32)
   at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
   at Function.Module._load (internal/modules/cjs/loader.js:530:3)
   at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
   at startup (internal/bootstrap/node.js:283:19)
   at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)
   at Object.<anonymous> ([...]/terrs/examples/example.js:3:47)
   at Module._compile (internal/modules/cjs/loader.js:689:30)
   at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
   at Module.load (internal/modules/cjs/loader.js:599:32)
   at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
   at Function.Module._load (internal/modules/cjs/loader.js:530:3)
   at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
   at startup (internal/bootstrap/node.js:283:19)
   at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)
 */

throw error;
/* =>
TError: The main error
    at Function.create ([...]/terrs/lib/terror.js:5:16)
    at Object.<anonymous> ([...]/terrs/examples/example.js:3:22)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)
Caused By: Error: The nested error
    at Object.<anonymous> ([...]/terrs/examples/example.js:3:47)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)
 */