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

@bakjs/dev-errors

v2.1.0-1

Published

Return better error details and skip the look at command line to catch the issue.

Downloads

12

Readme



Introduction

A hapi plugin to return an error view for web requests, providing more details of the issue. Also, provides the error stacktrace within the browser and you can skip the extra look at your command line to catch the issue.

hapi-dev-errors default error view

You can choose Youch to handle your error reporting by using the useYouch: true option. hapi-dev-errors integrates seamlessly with Youch and delegates the error handling, if activated. The view will look like this:

hapi-dev-errors Youch error view

Requirements

This plugin uses async/await which requires Node.js v8 or newer.

Installation

Add @bakjs/dev-errors as a dependency to your project:

npm i -S @bakjs/dev-errors
# you’re using NPM shortcuts to (i)nstall and (-S)ave the module as a dependency

# NPM v5 users, this way is yours
npm i @bakjs/dev-errors

Examples

Check out the examples directory and get an impression on how to configure hapi-dev-errors with the individual plugins options and how to customize the error view.

Usage

hapi-dev-errors is disabled by default to avoid leaking sensitive error details during production.

Enable the plugin by define a "truthy" value for the showErrors option.

The most straight forward way to register the hapi-dev-errors plugin:

await server.register({
    plugin: require('hapi-dev-errors'),
    options: {
      showErrors: process.env.NODE_ENV !== 'production'
    }
})

// went smooth like chocolate :)

Plugin Registration Options

The following plugin options allow you to customize the default behavior of hapi-dev-errors:

  • showErrors: (boolean), default: false — by default, the plugin is disabled and keeps hapi's default error handling behavior
  • useYouch: (boolean), default: false — use Youch to handle and display the error instead of using hapi-dev-error’s default handling
  • template: (string), no default — provide the template name that you want to render with h.view(template, errorData)
await server.register({
    plugin: require('hapi-dev-errors'),
    options: {
        showErrors: process.env.NODE_ENV !== 'production',
        template: 'my-error-view'
    }
})

// went smooth like chocolate :)

Provided Values for Your Custom Error View

hapi-dev-errors supports the template option while registering the plugin. Provide a template name to use your personal error template and not the default one shipped with hapi-dev-errors. In case you pass a string value for the template name, the view will be rendered with h.view(template, errorData).code(500).

Available properties to use in your custom error view:

  • title: error title like Internal Server Error
  • statusCode: HTTP response status code (always 500)
  • message: error message, like Uncaught error: h.view(...).test is not a function
  • method: HTTP request method, like GET
  • url: URL request path, like /signup
  • headers: HTTP request headers object, in key-value format
  • payload: HTTP request payload, only available for HTTP methods other than GET, in key-value format
  • stacktrace: error stacktrace

Feature Requests

Do you miss a feature? Please don’t hesitate to create an issue with a short description of your desired addition to this plugin.

Links & Resources

Contributing

  1. Create a fork
  2. Create your feature branch: git checkout -b my-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request 🚀

License

MIT © Future Studio


futurestud.io  ·  GitHub @fs-opensource  ·  Twitter @futurestud_io