1.1.8 • Published 4 years ago

@zestia/ember-error-handling v1.1.8

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

@zestia/ember-error-handling

The Ember guides suggest using Ember.onerror to handle errors and Ember.RSVP.on('error') to handle uncaught promise rejections. More often than not, you want to use the same handler for both these scenarios.

This Ember addon amalgamates the two hooks into a single top level error handler for your application.

It also allows specific errors to be squelched (ignored completely), which is paricularly useful when testing error scenarios.

Note If you are using await (native promises), rather than RSVP, and you still wish to have the ability to squelch errors - you must still wrap the chain with RSVP.resolve.

Installation

ember install @zestia/ember-error-handling
ember generate instance-initializer error-handling

Setup

// app/instance-initializers/error-handling.js

export function initialize(appInstance) {
  const errorHandlingService = appInstance.lookup('service:error-handling');

  errorHandlingService.onerror = (error) => {
    // Here is a good place to send the error to a third party.
  };

  errorHandlingService.squelch((error) => {
    // Return true to squelch
  });
}

export default {
  name: 'error-handling',
  initialize,
};

Example

test('something', async function (assert) {
  assert.expect(1);

  errorHandlingService.squelch((error) => {
    // Squelch can be called multiple times
  });
});
1.1.8

4 years ago

1.1.7

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.0

4 years ago

0.1.2

5 years ago

0.1.1

5 years ago