Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ember-error-logger

Package Overview
Dependencies
Maintainers
2
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ember-error-logger

Ember addon for handling and logging uncaught application errors

  • 0.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

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 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.

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 :-)

Keywords

FAQs

Package last updated on 20 Sep 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc