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

@gavant/ember-error-logger

v0.0.3

Published

Ember addon for handling and logging uncaught application errors

Downloads

3

Readme

ember-error-logger

ember-error-logger enables the handling and logging of uncaught errors. Handled error can be logged to a backend endpoint or passed through custom logic. By default, the addon includes consumers for local and remote logging of errors.

How it works

Errors thrown are caught by listener bound to error producers (window, Ember ...).
Errors handled by listeners are passed to various consumers which could log the error, render error page or perform additional logic. Consumers and listeners are both fully extendable and customizable.

Installation

  • ember install @gavant/ember-error-logger

then throw error somewhere in application and watch the console.

Configuration

Both listeners and consumers are enabled by defining an object with the property keys corresponding to the name/path of the object. To enable it with its default configuration, just set the property value to true, otherwise you may set it to a child object containing any valid configuration values.

Error Listeners

Define an Ember Object in app/error-listeners to use as listeners. Definition could be based on environment. Object must extend error-listeners/base-listener object.

// config/environment.js

if (environment === 'development' || environment === 'production') {
    ENV['ember-error-logger'].listeners = {
        'window-listener': true,
        'ember-listener': {
            ember: true,
            transitions: true,
            actions: true,
            rsvp: true
        }
    };
}

Note: the above configuration is the default for development and production environments.

Error Consumers

Define services to use as listeners. Definition could be based on environment. Service must extend error-consumers/base-consumer object. Consumers are executed in order.

// config/environment.js

if (environment === 'development') {
    ENV['ember-error-logger'].consumers = {
        'console-consumer': true
    };
}

if (environment === 'production') {
    ENV['ember-error-logger'].consumers = [
       'api-consumer': {
           endpoint: 'http://your-api.com/error-event'
       }
    ];
}

Note: by default, only the console-consumer is enabled in development.

api-consumer

The api-consumer allows errors to be easily sent to a backend along with some additional client information (user agent, resolution/viewport, current URL). In addition to adding the consumer to the consumers config object, you must define an endpoint in its child object which this information will be POST'ed to (see example consumers config above).

IMPORTANT The api-consumer uses ember-ajax to make the AJAX request. If you have extended the service with a custom host, you may need to adjust the ember-error-logger.consumers.api-consumer.endpoint value accordingly.

IMPORTANT If you need to modify the payload that is sent to the endpoint, you can override the api consumer and change the stringifyData method.

Handling all API related errors

Some API request errors may not be handled/logged by default (for example, if they are not triggered by a route transition). To log these errors, use the ember-error-logger/mixins/log-api-errors mixin in your ember-data adapter and/or ajax service. Additionally, this mixin will also stringify response payloads so that they can read in the error message (instead of just displaying as [object Object]).

Ember-exex

Addon plays nicely with Exceptional Exceptions addon: https://github.com/janmisek/ember-exex

Credits

Forked from and inspired by https://github.com/janmisek/ember-error-handler :-)