Skip to content

Commit

Permalink
fix: Filter exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
schw4rzlicht committed Jun 13, 2020
1 parent cef76ca commit 7777311
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
15 changes: 15 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"@d-fischer/typed-event-emitter": "^3.0.0",
"@sentry/node": "^5.17.0",
"ajv": "^6.12.2",
"bluebird": "^3.7.2",
"chalk": "^4.0.0",
"commander": "^5.1.0",
"dotenv": "^8.2.0",
Expand All @@ -51,6 +52,7 @@
"@types/lodash": "^4.14.152",
"@types/semver": "^7.2.0",
"@types/source-map-support": "^0.5.1",
"@types/bluebird-global": "^3.5.12",
"ajv-cli": "~3.1.0",
"jest": "^26.0.1",
"json2yaml": "^1.1.0",
Expand Down
7 changes: 5 additions & 2 deletions src/lib/Twitch2Ma.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ import ModeratorPermission from "./permissions/ModeratorPermission";

import sentry from "./sentry";

import * as Bluebird from "bluebird";
global.Promise = Bluebird as any;

import type Telnet from "telnet-client";

import SourceMapSupport = require("source-map-support");
Expand Down Expand Up @@ -153,7 +156,7 @@ export default class Twitch2Ma extends EventEmitter {
}
})
.then(() => this.emit(this.onCommandExecuted, channel, user, chatCommand, parameterName, instructions.consoleCommand))
.catch((error: PermissionError) => {
.catch(PermissionError, error => {
let reason = error.permissionCollector.permissionDeniedReasons.shift();
this.chatClient.say(channel, reason.viewerMessage);
this.emit(this.onPermissionDenied, channel, user, reason.name);
Expand Down Expand Up @@ -214,7 +217,7 @@ export default class Twitch2Ma extends EventEmitter {
try {
super.emit(event, ...args);
} catch (error) {
console.error(error);
sentry(error);
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ function init(): void {
.then(config => new Twitch2Ma(config))
.then(attachEventHandlers)
.then(twitch2Ma => twitch2Ma.start())
.catch((error: ConfigError | TelnetError) => exitWithError(error))
// @ts-ignore
.catch(ConfigError, TelnetError, error => exitWithError(error))
.catch(error => sentry(error, exitWithError));
})
.parse(process.argv);
Expand Down

0 comments on commit 7777311

Please sign in to comment.