1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const notifier_1 = require("./notifier");
|
4 | class ErrorReporter {
|
5 | constructor(notifier) {
|
6 | this.notifier = notifier;
|
7 | }
|
8 | reportError(error) {
|
9 | this.notifier.emit(notifier_1.GraphiteEvent.DidError, { error });
|
10 | }
|
11 | onError(handler) {
|
12 | return this.notifier.on(notifier_1.GraphiteEvent.DidError, async (...args) => {
|
13 | try {
|
14 | await handler(...args);
|
15 | }
|
16 | catch (ex) {
|
17 | console.error('Exception thrown in ErrorReporter#onError handler', ex);
|
18 | }
|
19 | });
|
20 | }
|
21 | }
|
22 | exports.errorReporter = new ErrorReporter(notifier_1.createNotifier());
|
23 |
|
\ | No newline at end of file |