1.0.5 • Published 1 year ago

throw-http v1.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Introduction

Throw-http is an Error utility for handling http errors in a delightful way. I created it because existing libraries are not type-safe, not correctly exported or don't allow to pass additional data in the error.

Installation

To get started, install http-throw using npm or yarn:

npm install throw-http
# or
yarn add throw-http

Usage

Throwing an ThrowHttp error

import { ThrowHttp } from 'throw-http';

throw new ThrowHttp.NotFound('User not found');

Throwing a custom ThrowHttp error

import { ThrowHttp } from 'throw-http';

throw new ThrowHttp({ code: 500, name: 'Badaboom' });

Typeguard for ThrowHttp

import { ThrowHttp } from 'throw-http';

try {
  // some code
} catch (error) {
  if (ThrowHttp.isThrowHttp(error)) {
    // handle http error
  }
}
1.0.5

1 year ago

1.0.4

1 year ago

1.0.2

1 year ago

1.0.3

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago