1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | Object.defineProperty(exports, "__esModule", { value: true });
|
13 | const errorSource_1 = require("../constants/errorSource");
|
14 | const Feathers_1 = require("../services/Feathers");
|
15 | const env_1 = require("../constants/env");
|
16 | const { UNEXPECTED } = errorSource_1.errorSource;
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 | async function error(options) {
|
25 | const { accessToken } = options;
|
26 | if (accessToken) {
|
27 | const api = new Feathers_1.FeathersClient();
|
28 | await api
|
29 | .create('/log/event', { metadata: options.err }, {
|
30 | headers: {
|
31 | Authorization: accessToken,
|
32 | },
|
33 | })
|
34 | .catch(err => {
|
35 | this.debug('%O', err);
|
36 | });
|
37 | }
|
38 | const { extra, message } = options.err;
|
39 | if (extra && extra.source === UNEXPECTED) {
|
40 | this.log(`\n 😰 We've encountered a problem. Please try again or contact ${env_1.INTERCOM_EMAIL} and we'll do our best to help. \n`);
|
41 | process.exit(1);
|
42 | }
|
43 | this.log(`\n ${message}`);
|
44 | if (extra && extra.exit)
|
45 | process.exit();
|
46 | }
|
47 | exports.default = error;
|