1 |
|
2 | const {AnalyticsService, ReportService} = require('@gigster/gig-services');
|
3 |
|
4 |
|
5 | const guard = async (callback) => {
|
6 | try {
|
7 |
|
8 |
|
9 | process.death = process.exit;
|
10 | process.exit = () => {};
|
11 |
|
12 | await callback();
|
13 | } catch (error) {
|
14 | ReportService.reportError(error);
|
15 |
|
16 |
|
17 | console.log(
|
18 | `For help, please contact Gigster ` +
|
19 | `via the '/dev-support' slack command.`);
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 | process.exitCode = 1;
|
26 | }
|
27 |
|
28 | AnalyticsService.flushSegment();
|
29 | };
|
30 |
|
31 |
|
32 | module.exports = guard;
|