Skip to content

Commit e0aa290

Browse files
authored
Show helpful admin command error if it's a IrcProvisioningError (#1702)
* Check if instance of IrcProvisioningError * changelog * Fix a typing bug.
1 parent 016ae17 commit e0aa290

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

changelog.d/1702.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Show a helpful error for !link/!unlink admin failures, rather than "Check the logs for details", in more cases.

src/bridge/AdminRoomHandler.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import * as RoomCreation from "./RoomCreation";
2727
import { getBridgeVersion } from "matrix-appservice-bridge";
2828
import { IdentGenerator } from "../irc/IdentGenerator";
2929
import { Provisioner } from "../provisioning/Provisioner";
30+
import { IrcProvisioningError } from "../provisioning/Schema";
3031

3132
const log = logging("AdminRoomHandler");
3233

@@ -239,6 +240,9 @@ export class AdminRoomHandler {
239240
}
240241
catch (ex) {
241242
log.error(`Failed to handle !plumb command:`, ex);
243+
if (ex instanceof IrcProvisioningError) {
244+
return new MatrixAction(ActionType.Notice, `Failed to plumb room. ${ex.message}`);
245+
}
242246
return new MatrixAction(ActionType.Notice, "Failed to plumb room. Check the logs for details.");
243247
}
244248
return new MatrixAction(ActionType.Notice, "Room plumbed.");
@@ -272,6 +276,9 @@ export class AdminRoomHandler {
272276
}
273277
catch (ex) {
274278
log.error(`Failed to handle !unlink command:`, ex);
279+
if (ex instanceof IrcProvisioningError) {
280+
return new MatrixAction(ActionType.Notice, `Failed to plumb room. ${ex.message}`);
281+
}
275282
return new MatrixAction(ActionType.Notice, "Failed to unlink room. Check the logs for details.");
276283
}
277284
return new MatrixAction(ActionType.Notice, "Room unlinked.");
@@ -282,7 +289,7 @@ export class AdminRoomHandler {
282289
// check that the server exists and that the user_id is on the whitelist
283290
const ircChannel = args[0];
284291
const key = args[1]; // keys can't have spaces in them, so we can just do this.
285-
let errText = null;
292+
let errText: string|null = null;
286293
if (!ircChannel || !ircChannel.startsWith("#")) {
287294
errText = "Format: '!join irc.example.com #channel [key]'";
288295
}

0 commit comments

Comments
 (0)