Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@adonisjs/generic-exceptions

Package Overview
Dependencies
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@adonisjs/generic-exceptions

List of generic exceptions to be used in all other repos

  • 3.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
16K
increased by6.1%
Maintainers
2
Weekly downloads
 
Created
Source

AdonisJs Generic Exceptions 🚀

Customized exceptions for AdonisJs

NPM Version

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.

npm i @adonisjs/generic-exceptions

Usage

The package exports all exceptions from node-exceptions and adds additional methods to the RuntimeException class.

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

Keywords

FAQs

Package last updated on 20 Oct 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc