# @adonisjs/generic-exceptions

> List of generic exceptions to be used in all other repos

Latest version **3.0.1** (published 2018-10-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install @adonisjs/generic-exceptions
pnpm add @adonisjs/generic-exceptions
yarn add @adonisjs/generic-exceptions
bun add @adonisjs/generic-exceptions
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.1 |
| Published | 2018-10-20 |
| First published | 2017-08-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 8.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 11 |
| Author | virk |
| Maintainers | romainlanz, virk |
| Keywords | adonisjs, adonis, exceptions |

## Links

- npm: https://www.npmjs.com/package/@adonisjs/generic-exceptions
- Repository: https://github.com/adonisjs/adonis-generic-exceptions
- Homepage: https://github.com/adonisjs/adonis-generic-exceptions#readme
- Issues: https://github.com/adonisjs/adonis-generic-exceptions/issues
- npm.io page: https://npm.io/package/@adonisjs/generic-exceptions

## Dependencies (2)

- [upcast](https://npm.io/package/upcast.md) ^4.0.0
- [node-exceptions](https://npm.io/package/node-exceptions.md) ^4.0.1

## Recent versions

- 3.0.1 (latest) — 2018-10-20
- 3.0.0 — 2018-10-20
- 2.0.1 — 2018-05-11
- 2.0.0 — 2018-01-16
- 1.0.0 — 2017-08-01

## README

# AdonisJs Generic Exceptions 🚀
> Customized exceptions for AdonisJs

[![NPM Version][npm-image]][npm-url]

This repo contains some helpful classes to throw uniform exceptions through out the application. Ofcourse you can throw exceptions using `new Error()` but using this package will help in throwing informative exceptions.

## Setup
Install package using npm.

```shell
npm i @adonisjs/generic-exceptions
```

## Usage
The package exports all exceptions from [node-exceptions](https://poppinss.github.io/node-exceptions/docs/index.html) and adds additional methods to the `RuntimeException` class.

```js
const { InvalidArgumentException } = require('@adonisjs/generic-exceptions')

const message = 'Model.create requires an object'
const status = 400
const code = 'E_INVALID_ARGUMENT'

throw new InvalidArgumentException(message, status, code)
```

The `status` must be a valid HTTP status code and `code` is a unique error code to recognize an exception. AdonisJs error codes starts with `E_`, for example: `E_MISSING_CONFIG`.

## RuntimeException
The following static methods are added to the runtime exception to make the adonisJs related exceptions consistent.

#### missingConfig(key, file)
#### missingAppKey(providerName)
#### incompleteConfig(missingKeys, file)
#### invoke(message, status, [code])

Checkout the complete API docs [here](https://adonisjs.github.io/adonis-generic-exceptions/docs/classes/main.runtimeexception.html)

[npm-image]: https://img.shields.io/npm/v/@adonisjs/generic-exceptions.svg?style=flat-square
[npm-url]: https://npmjs.org/package/@adonisjs/generic-exceptions

---
_Source: https://npm.io/package/@adonisjs/generic-exceptions · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
