@adobe/contentlake-shared-rest-error

1.0.0 • Public • Published

Content Lake Shared - REST Error

Error type for returning rfc9457 problem responses

This is one of the Content Lake Shared libraries.

Status

GitHub license

Usage

Install using:

npm install @adobe/contentlake-shared-rest-error

Use with:

import { RestError } from '@adobe/contentlake-shared-rest-error';

throw new RestError(400, 'Missing some field');

Additional Properties

To add additional requests to the error body provide a third parameter as an Object:

throw new RestError(400, 'Missing some field', { fields: ['field1', 'field2']});

Converting to a Problem Response

The static method toProblemResponse can convert any object (including RestError objects) into a rfc9457 problem responses:

RestError.toProblemResponse(err);

In addition, you can provide a second context parameter from which the method will extract an instance from the invocation:

RestError.toProblemResponse(err, context);

Readme

Keywords

none

Package Sidebar

Install

npm i @adobe/contentlake-shared-rest-error

Weekly Downloads

5

Version

1.0.0

License

Apache-2.0

Unpacked Size

20.4 kB

Total Files

5

Last publish

Collaborators

  • stopp-adobe
  • dylandepass
  • djaeggi
  • adobehalls
  • fullcolorcoder
  • marbec
  • tripod
  • garthdb
  • lazd
  • adobe-admin
  • patrickfulton
  • trieloff
  • shazron
  • krisnye
  • dcpfsdk
  • natebaldwin
  • devongovett
  • aspro83
  • symanovi
  • dpfister
  • stefan-guggisberg
  • korra
  • rofe
  • kptdobe