npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@synanetics/errors

v2.0.2

Published

Set of Synanetics common errors for applications to use

Downloads

157

Readme

@synanetics/errors

Utility Synanetics errors for application usage

SynaneticsOutcomeError

Takes message and optional options parameters. Extends default Error interface with support for cause and in addition takes optional outcome and status properties.

SynaneticsOutcomeError.outcome

The outcome property is expected to be an OperationOutcome resource. If not supplied then a default OperationOutcome with severity of 'error', code of 'invalid' and diagnostics matching the message parameter is created.

SynaneticsOutcomeError.status

The status property is expected to be a number, it defaults to 500 assuming the value is meant for HTTP status code representation but in theory could be any desired number system.

Usage

const { SynaneticsOutcomeError } = require('@synanetics/errors');
// or
import { SynaneticsOutcomeError } from '@synanetics/errors';

const outcomeError1 = new SynaneticsOutcomeError('some message');

const outcomeError2 = new SynaneticsOutcomeError('example', {
  outcome: { resourceType: 'OperationOutcome' ... },
  status: 400,
  cause: outcomeError1,
});

HttpStatusCodeOutcomeError

Creates Error objects with extended outcome and status properties to represent HTTP related errors. message parameter can be an array of strings to generate multiple issue entries.

HttpStatusCodeOutcomeError.outcome

The outcome property will be an OperationOutcome resource.

HttpStatusCodeOutcomeError.status

The status property will be a number representing a HTTP status code.

static methods

A number of static methods are available to ease creation of specific types of error that map to the NHS Booking and Referral Standard:

badRequestError() -> BAD_REQUEST
conflictError() -> CONFLICT
forbiddenError() -> FORBIDDEN
methodNotAllowedError() -> METHOD_NOT_ALLOWED
notAcceptableError() -> NOT_ACCEPTABLE
notFoundError() -> NOT_FOUND
notImplementedError() -> NOT_IMPLEMENTED
proxyBadRequestError() -> PROXY_BAD_REQUEST
proxyConflictError() -> PROXY_CONFLICT
proxyForbiddenError() -> PROXY_FORBIDDEN
proxyMethodNotAllowedError() -> PROXY_METHOD_NOT_ALLOWED
proxyNotFoundError() -> PROXY_NOT_FOUND
proxyNotImplementedError() -> PROXY_NOT_IMPLEMENTED
proxyServerError() -> PROXY_SERVER_ERROR
proxyTimeoutError() -> PROXY_TIMEOUT
proxyTooManyRequestsError() -> PROXY_TOO_MANY_REQUESTS
proxyUnauthorizedError() -> PROXY_UNAUTHORIZED
proxyUnavailableError() -> PROXY_UNAVAILABLE
proxyUnprocessableEntityError() -> PROXY_UNPROCESSABLE_ENTITY
recBadRequestError() -> REC_BAD_REQUEST
recConflictError() -> REC_CONFLICT
recForbiddenError() -> REC_FORBIDDEN
recMethodNotAllowedError() -> REC_METHOD_NOT_ALLOWED
recNotAcceptableError() -> REC_NOT_ACCEPTABLE
recNotFoundError() -> REC_NOT_FOUND
recNotImplementedError() -> REC_NOT_IMPLEMENTED
recServerError() -> REC_SERVER_ERROR
recTimeoutError() -> REC_TIMEOUT
recUnauthorizedError() -> REC_UNAUTHORIZED
recUnavailableError() -> REC_UNAVAILABLE
recUnprocessableEntityError() -> REC_UNPROCESSABLE_ENTITY
sendBadRequestError() -> SEND_BAD_REQUEST
sendConflictError() -> SEND_CONFLICT
sendForbiddenError() -> SEND_FORBIDDEN
sendMethodNotAllowedError() -> SEND_METHOD_NOT_ALLOWED
sendNotAcceptableError() -> SEND_NOT_ACCEPTABLE
sendNotImplementedError() -> SEND_NOT_IMPLEMENTED
sendTooManyRequestsError() -> SEND_TOO_MANY_REQUESTS
sendUnauthorizedError() -> SEND_UNAUTHORIZED
sendUnprocessableEntityError() -> SEND_UNPROCESSABLE_ENTITY
serverError() -> SERVER_ERROR
timeoutError() -> TIMEOUT
tooManyRequestsError() -> TOO_MANY_REQUESTS
unauthorizedError() -> UNAUTHORIZED
unavailableError() -> UNAVAILABLE
unprocessableEntityError() -> UNPROCESSABLE_ENTITY

Additional static methods exist to create outcome errors from HTTP status codes:

HttpStatusCodeOutcomeError.errorFromStatusCode(code, message);
HttpStatusCodeOutcomeError.proxyErrorFromStatusCode(code, message);
HttpStatusCodeOutcomeError.recErrorFromStatusCode(code, message);
HttpStatusCodeOutcomeError.sendEerrorFromStatusCode(code, message);