Skip to content
This repository was archived by the owner on Jun 16, 2022. It is now read-only.
jorenkoyenPublic archive

About

HTTP problem details model based on RFC7808

Resources

Stars

2 stars

Watchers

1 watching

Forks

Latest commit

 

History

19 Commits

Folders and files

Repository files navigation

Problem Details

npm version

HTTP problem details model based on RFC7807. This package wraps the default Error object to throw better defined errors which are previously registered. This ensures that thrown errors are more consistent.

Install

npm install --save problem-details

Basic Example

import { ProblemDefinition, DetailFactory, DefinitionFactory } from 'problem-details';

// setup definition factory
const definitionFactory = new DefinitionFactory();
definitionFactory.load([
  {
    code: 'C001',
    status: 400,
    title: 'You do not have enough credit',
    type: 'https://www.example.com/support/C001'
  }
]);

// setup detail factory
const detailFactory = new DetailFactory(definitionFactory);

// ...
// throw error
throw detailFactory.createFromCode('C001');

About

HTTP problem details model based on RFC7808

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages