1.0.8 • Published 1 year ago

handle-api-error v1.0.8

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

handle-api-error

  • Micro package for handling api errors. Provides simple function to help with debugging errors within APIs

Installation

```bash
npm install handle-api-error

Usage

const handleApiError = require('handle-api-error');

try {
    // Do something
} catch {
    throw handleApiError(error, "Doing something", 506, true); // Returns an error 
}

API

handleApiError(error, message, statusCode, expose)

  • Handles an API error.

Params:

  • error: Error that has been caught, that will be handled
  • message: String message to be displayed in the error
  • statusCode: Number status code to be displayed in the error, corresponds to a HTTP status code, default 400
  • expose: Boolean if the error should be exposed to the user, default true
1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago