Better handle registration errors

This commit is contained in:
Simon Ser
2020-08-25 11:42:40 +02:00
parent b23f55a840
commit 516de5b3ea
2 changed files with 25 additions and 5 deletions

View File

@@ -93,10 +93,6 @@ export default class Client extends EventTarget {
console.log("Registration complete");
this.registered = true;
break;
case irc.ERR_PASSWDMISMATCH:
this.dispatchEvent(new CustomEvent("error", { detail: "Password mismatch" }));
this.close();
break;
case "CAP":
this.handleCap(msg);
break;
@@ -148,6 +144,22 @@ export default class Client extends EventTarget {
deleteBatch = name;
}
break;
case "ERROR":
this.dispatchEvent(new CustomEvent("error", { detail: "Fatal IRC error: " + msg.params[0] }));
this.close();
break;
case irc.ERR_PASSWDMISMATCH:
case irc.ERR_ERRONEUSNICKNAME:
case irc.ERR_NICKNAMEINUSE:
case irc.ERR_NICKCOLLISION:
case irc.ERR_UNAVAILRESOURCE:
case irc.ERR_NOPERMFORHOST:
case irc.ERR_YOUREBANNEDCREEP:
this.dispatchEvent(new CustomEvent("error", { detail: "Error (" + msg.command + "): " + msg.params[msg.params.length - 1] }));
if (!this.registered) {
this.close();
}
break;
}
this.dispatchEvent(new CustomEvent("message", {