Handle all errors

This commit is contained in:
Mattias Erming 2014-06-13 15:57:11 +02:00
parent 047f8b0302
commit 95596f4039

View File

@ -17,6 +17,7 @@ var sockets = null;
var networks = []; var networks = [];
var events = [ var events = [
"errors",
"join", "join",
"kick", "kick",
"mode", "mode",
@ -374,6 +375,16 @@ function event(e, data) {
var channels = this.channels; var channels = this.channels;
switch (e) { switch (e) {
case "errors":
sockets.emit("msg", {
msg: new Msg({
type: "error",
from: "-!-",
text: data.message,
}),
});
break;
case "join": case "join":
var chan = _.findWhere(channels, {name: data.channel}); var chan = _.findWhere(channels, {name: data.channel});
if (typeof chan === "undefined") { if (typeof chan === "undefined") {
@ -652,14 +663,8 @@ function event(e, data) {
case "whois": case "whois":
if (!data) { if (!data) {
sockets.emit("msg", { break;
msg: new Msg({ }
type: "error",
from: "-!-",
text: "No such nick/channel.",
}),
});
} else {
var chan = _.findWhere(channels, {name: data.nickname}); var chan = _.findWhere(channels, {name: data.nickname});
if (typeof chan === "undefined") { if (typeof chan === "undefined") {
chan = new Chan({ chan = new Chan({
@ -681,7 +686,7 @@ function event(e, data) {
var i = 0; var i = 0;
for (var k in data) { for (var k in data) {
var key = prefix[k]; var key = prefix[k];
if (!key) { if (!key || data[k].toString() == "") {
continue; continue;
} }
var msg = new Msg({ var msg = new Msg({
@ -705,7 +710,6 @@ function event(e, data) {
id: chan.id, id: chan.id,
msg: msg, msg: msg,
}); });
}
break; break;
} }
} }