0.0.8 • Published 5 years ago

@specialblend/pretty-error v0.0.8

Weekly downloads
1
License
ISC
Repository
github
Last release
5 years ago

pretty-error

Readable, property-bearing custom ES6 errors for Node.js

install

npm install @specialblend/pretty-error

Example

import PrettyError from '@specialblend/pretty-error';

class JSONError extends PrettyError {}

export const parseJSON = str => {
  try {
    return JSON.parse(str);
  } catch (err) {
    throw new JSONError('Invalid JSON!', { str })
  }
}

Output:

JSONError: Invalid JSON!
{
  str: '{this;is-not.valid/json'
}
    at parseJSON (/Users/specialblend/workspace/pretty-error/examples/parse-json.js:11:15)
    at Object.parseJSON (/Users/specialblend/workspace/pretty-error/examples/parse-json.js:15:1)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Module._compile (/Users/specialblend/workspace/pretty-error/node_modules/pirates/lib/index.js:99:24)
    at Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Object.newLoader [as .js] (/Users/specialblend/workspace/pretty-error/node_modules/pirates/lib/index.js:104:7)
    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)
0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago

0.0.0

5 years ago