JSPM

http-rest-errors

1.0.5
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 8
  • Score
    100M100P100Q28620F
  • License ISC

Package Exports

  • http-rest-errors
  • http-rest-errors/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (http-rest-errors) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

http-rest-errors

Lib para facilitar lançamento de erros

Como utilizar:

import { BadRequestError, GenericError } from 'http-rest-errors'

Você pode utilizar um erro específico como o BadRequest, exemplo

const error: BadRequestError = new BadRequestError()

Esta classe pode receber dois parâmetros, mensagem: string e o erro: any

const message: string = 'mensagem de erro'
const e: any = {
    error: 'error'
}
const error: BadRequestError = new BadRequestError(message, e)

Outra opção é criar um erro Genérico

const error: GenericError = new GenericError()

Você também poderá passar parâmetros para instanciar esta classe

const message: string = 'mensagem de teste erro'
const status: number = 401
const error: GenericError = new GenericError(message, status)