npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@itavy/ierror

v1.2.0

Published

Error module for @itavy namespace

Downloads

10

Readme

IError

This is a module provides support for some missing features of native errors, working as a drop in replacement for native errors:

  • chain of causes
  • custom information for the error
  • timestamp of the error occurrence
  • serialization and composing back the object from serialization

Instalation

npm install @itavy/ierror

Quick Example

const IError = require('@itavy/ierror').IError;

const err = new IError('test error');
console.log(err);

this will produce:

{ ERROR: test error
    at Object.<anonymous> (/**********/test.js:3:13)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:394:7)
    at startup (bootstrap_node.js:149:9)
    at bootstrap_node.js:509:3
  name: 'ERROR',
  ts: 1492430124565,
  severity: 'ERROR',
  source: null,
  code: null,
  extra: null }

API

itavy/ierror : object

Kind: global namespace

itavy/ierror.IError

Error struture

Kind: static class of itavy/ierror

new IError(options)

| Param | Type | Description | | --- | --- | --- | | options | IErrorLiteral | error info |

iError.message : String

Error message

Kind: instance property of IError

iError.name : String

Error name

Kind: instance property of IError
Default: 'ERROR'

iError.ts : Number

Error UNIX timestamp

Kind: instance property of IError
Default: Date.now()

iError.severity : String

Error severity

Kind: instance property of IError
Default: 'ERROR'

iError.source : String

Error source

Kind: instance property of IError
Default: null

iError.code : String

Error code

Kind: instance property of IError
Default: null

iError.extra : *

Error extra information

Kind: instance property of IError
Default: null

iError.origStack : String

Error stack trace

Kind: instance property of IError
Default: null
Read only: true

iError.cause : IError

Error cause

Kind: instance property of IError
Default: null
Read only: true

iError.toJSON() ⇒ IErrorLiteral

get IError literal representation

Kind: instance method of IError
Returns: IErrorLiteral - IError literal representation
Access: public

iError.toString() ⇒ String

get IError json stringify

Kind: instance method of IError
Returns: String - JSON representation of IError
Access: public

iError.hasErrorWithName(name) ⇒ Boolean

Check all cause chain to see if an error with requested name exists

Kind: instance method of IError
Returns: Boolean - true if an error with a name exists
Access: public

| Param | Type | Description | | --- | --- | --- | | name | String | name of the error to look after |

iError.hasErrorWithCode(code) ⇒ Boolean

Check all cause chain to see if an error with requested code exists

Kind: instance method of IError
Returns: Boolean - true if an error with a code exists
Access: public

| Param | Type | Description | | --- | --- | --- | | code | String | code of the error to look after |

iError.getErrorWithName(name) ⇒ IError | null

Traverse all chain to get error with requested name

Kind: instance method of IError
Returns: IError | null - IError found or null otherwise
Access: public

| Param | Type | Description | | --- | --- | --- | | name | String | name of the error to look after |

iError.getErrorWithCode(code) ⇒ IError | null

Traverse all chain to get error with requested code

Kind: instance method of IError
Returns: IError | null - IError found or null otherwise
Access: public

| Param | Type | Description | | --- | --- | --- | | code | String | code of the error to look after |

itavy/ierror.rejectIError(request) ⇒ Promise

Rejects with IError

Kind: static method of itavy/ierror
Returns: Promise - rejects with an IError

| Param | Type | Description | | --- | --- | --- | | request | IErrorLiteral | Error | IError | error to reject with |

itavy/ierror.resolveIError(request) ⇒ Promise

Resolves with IError

Kind: static method of itavy/ierror
Returns: Promise - resolves with an IError
Access: public

| Param | Type | Description | | --- | --- | --- | | request | Object | error to resolve with |

itavy/ierror.IErrorLiteral : Object

Kind: static typedef of itavy/ierror
Properties

| Name | Type | Default | Description | | --- | --- | --- | --- | | message | String | | Error message | | [name] | String | 'ERROR' | Error name | | [ts] | Number | Date.now() | Error UNIX timestamp | | [severity] | String | 'ERROR' | Error severity | | [source] | String | | Error source | | [code] | String | | Error code | | [extra] | * | | Extra information needed to be held with the error | | [cause] | IError | Error | null | | original cause which triggered | | [origStack] | String | | stack of the error this error on chain |

Usage

see Example

LICENSE

MIT