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

@dannybster/expected-errors

v0.7.0

Published

A collection of expected errors that can be raised and middleware for handling/responding to them.

Downloads

14

Readme

Codeship Status for dannybster/expected-errors

expected-errors

A collection of expected errors that can be raised and middleware for handling/responding to them.

Version 0.7.0

  • Added #isExternalServiceError.
  • Renamed #handleExpectedError to #handleHttpError as it is a better explanation of what it does.
  • Added #createExternalServiceError.
  • Exported #createHttpError for creating generic expected http errors.

Version 0.6.0

  • #createUnauthorizedError now accepts an original error parameter that will be accessible by calling cause() on the error returned from #createUnauthorizedError.
  • Unauthorized errors now have the name UnauthorizedError.
  • Unauthorized errors now have the message Unauthorized Error.

Version 0.5.0

  • handleExpectedError now only sends a response if the headers have not been sent. This is to cater for the use case of an error being raised by a longer running operation that runs on the server but the server has already told the client that everything is ok to aid with performance.

Version 0.4.0

  • Updated createNotFoundError to take an error object parameter that will become the cause of not found error returned.

Version 0.3.0

  • Added createConflictError.
  • Added isConflictError.

Version 0.2.4

  • Added the verror dependancy back as it turns out the way verror handles messages is very handy for logging (it concatenates it's causes).
  • Added a name property of ServiceUnavailableError to service unavailable errors.
  • Added a code property of 503 to service unavailable errors.

Version 0.2.3

  • Added the standard bunyan serializers when creating the log object so that error logging provides details, as a side effect req and res objects will also be serialized as per the bunyan standard serializers: https://github.com/trentm/node-bunyan#standard-serializers

Version 0.2.2

  • Changed the interface of createServiceUnavailableError to just take a cause
    as the thinking is the type of error is descriptive enough. That is any expected error should just be a type wrapper for a cause. Internally it is possible to set a message suce as Service Unavailable Error.
  • Removed the reliance on verror as the only thing we were using for was the cause function.
  • These changes have only been applied to createSericeUnavailableError for now to see how they sit in the context of an application.

Version 0.2.1

  • Removed the usage of rewire as it was not needed and made the tests harder to read.

Version 0.2.0

  • Added a 503 Service unavailable error.
  • Added logError error middleware.

Version 0.1.0

  • Added a 404 Not Found error.
  • Added a 401 Unauthorized error.
  • Added the middleware function handleExpectedError to deal with the above errors.