Rename "errCB" to "constructErrorCallback" to improve readability

This commit is contained in:
meew0
2015-12-31 18:54:44 +01:00
parent 45c936e1ad
commit 415260d028

View File

@@ -4,7 +4,7 @@ import InternalClient from "./InternalClient";
import EventEmitter from "events";
import PMChannel from "../Structures/PMChannel";
function errCB(callback) {
function constructErrorCallback(callback) {
return error => {
callback(error);
throw error;
@@ -72,13 +72,13 @@ export default class Client extends EventEmitter {
.then(token => {
callback(null, token);
return token;
}, errCB(callback));
}, constructErrorCallback(callback));
}
// def logout
logout(callback = (/*err*/) => { }) {
return this.internal.logout()
.then(callback, errCB(callback));
.then(callback, constructErrorCallback(callback));
}
// def destroy
@@ -100,7 +100,7 @@ export default class Client extends EventEmitter {
.then(m => {
callback(null, m);
return m;
}, errCB(callback));
}, constructErrorCallback(callback));
}
// def sendTTSMessage
@@ -109,7 +109,7 @@ export default class Client extends EventEmitter {
.then(m => {
callback(null, m);
return m;
}, errCB(callback));
}, constructErrorCallback(callback));
}
// def reply
reply(where, content, options = {}, callback = (/*e, m*/) => { }) {
@@ -128,7 +128,7 @@ export default class Client extends EventEmitter {
.then(m => {
callback(null, m);
return m;
}, errCB(callback));
}, constructErrorCallback(callback));
}
var err = new Error("Destination not resolvable to a message!");
callback(err);
@@ -141,7 +141,7 @@ export default class Client extends EventEmitter {
.then(m => {
callback(null, m);
return m;
}, errCB(callback));
}, constructErrorCallback(callback));
}
// def deleteMessage
deleteMessage(msg, options = {}, callback = (/*e*/) => { }) {
@@ -151,7 +151,7 @@ export default class Client extends EventEmitter {
}
return this.internal.deleteMessage(msg, options)
.then(callback, errCB(callback));
.then(callback, constructErrorCallback(callback));
}
//def updateMessage
updateMessage(msg, content, options = {}, callback = (/*err, msg*/) => { }) {
@@ -164,7 +164,7 @@ export default class Client extends EventEmitter {
.then(msg => {
callback(null, msg);
return msg;
}, errCB(callback));
}, constructErrorCallback(callback));
}
// def getChannelLogs
@@ -178,7 +178,7 @@ export default class Client extends EventEmitter {
.then(logs => {
callback(null, logs);
return logs;
}, errCB(callback));
}, constructErrorCallback(callback));
}
// def getBans
@@ -187,7 +187,7 @@ export default class Client extends EventEmitter {
.then(bans => {
callback(null, bans);
return bans;
}, errCB(callback));
}, constructErrorCallback(callback));
}
// def sendFile
@@ -196,7 +196,7 @@ export default class Client extends EventEmitter {
.then(m => {
callback(null, m);
return m;
}, errCB(callback));
}, constructErrorCallback(callback));
}
// def joinServer
@@ -205,7 +205,7 @@ export default class Client extends EventEmitter {
.then(srv => {
callback(null, srv);
return srv;
}, errCB(callback));
}, constructErrorCallback(callback));
}
// def createServer
@@ -214,19 +214,19 @@ export default class Client extends EventEmitter {
.then(srv => {
callback(null, srv);
return srv;
}, errCB(callback));
}, constructErrorCallback(callback));
}
// def leaveServer
leaveServer(server, callback = (/*err*/) => { }) {
return this.internal.leaveServer(server)
.then(callback, errCB(callback));
.then(callback, constructErrorCallback(callback));
}
// def deleteServer
deleteServer(server, callback = (/*err*/) => { }) {
return this.internal.leaveServer(server)
.then(callback, errCB(callback));
.then(callback, constructErrorCallback(callback));
}
// def createChannel
@@ -239,13 +239,13 @@ export default class Client extends EventEmitter {
.then(channel => {
callback(channel);
return channel;
}, errCB(callback));
}, constructErrorCallback(callback));
}
// def deleteChannel
deleteChannel(channel, callback = (/*err*/) => { }) {
return this.internal.deleteChannel(channel)
.then(callback, errCB(callback));
.then(callback, constructErrorCallback(callback));
}
//def banMember
@@ -256,19 +256,19 @@ export default class Client extends EventEmitter {
callback = length;
}
return this.internal.banMember(user, server, length)
.then(callback, errCB(callback));
.then(callback, constructErrorCallback(callback));
}
//def unbanMember
unbanMember(user, server, callback = (/*err*/) => { }) {
return this.internal.unbanMember(user, server)
.then(callback, errCB(callback));
.then(callback, constructErrorCallback(callback));
}
//def kickMember
kickMember(user, server, callback = (/*err*/) => { }) {
return this.internal.kickMember(user, server)
.then(callback, errCB(callback));
.then(callback, constructErrorCallback(callback));
}
//def createRole
@@ -281,7 +281,7 @@ export default class Client extends EventEmitter {
.then(role => {
callback(null, role);
return role;
}, errCB(callback));
}, constructErrorCallback(callback));
}
//def updateRole
@@ -294,19 +294,19 @@ export default class Client extends EventEmitter {
.then(role => {
callback(null, role);
return role;
}, errCB(callback));
}, constructErrorCallback(callback));
}
//def deleteRole
deleteRole(role, callback = (/*err*/) => { }) {
return this.internal.deleteRole(role)
.then(callback, errCB(callback));
.then(callback, constructErrorCallback(callback));
}
//def addMemberToRole
addMemberToRole(member, role, callback = (/*err*/) => { }) {
return this.internal.addMemberToRole(member, role)
.then(callback, errCB(callback));
.then(callback, constructErrorCallback(callback));
}
// def addUserToRole
@@ -317,7 +317,7 @@ export default class Client extends EventEmitter {
// def removeMemberFromRole
removeMemberFromRole(member, role, callback = (/*err*/) => { }) {
return this.internal.removeMemberFromRole(member, role)
.then(callback, errCB(callback));
.then(callback, constructErrorCallback(callback));
}
// def removeUserFromRole
@@ -328,7 +328,7 @@ export default class Client extends EventEmitter {
//def addMemberToRole
addMemberToRoles(member, roles, callback = (/*err*/) => { }) {
return this.internal.addMemberToRoles(member, roles)
.then(callback, errCB(callback));
.then(callback, constructErrorCallback(callback));
}
// def addUserToRole
@@ -339,7 +339,7 @@ export default class Client extends EventEmitter {
// def removeMemberFromRole
removeMemberFromRoles(member, roles, callback = (/*err*/) => { }) {
return this.internal.removeMemberFromRoles(member, roles)
.then(callback, errCB(callback));
.then(callback, constructErrorCallback(callback));
}
// def removeUserFromRole
@@ -358,19 +358,19 @@ export default class Client extends EventEmitter {
return this.internal.createInvite(chanServ, options)
.then(invite => {
callback(null, invite);
}, errCB(callback));
}, constructErrorCallback(callback));
}
// def deleteInvite
deleteInvite(invite, callback = (/*err*/) => { }) {
return this.internal.deleteInvite(invite)
.then(callback, errCB(callback));
.then(callback, constructErrorCallback(callback));
}
// def overwritePermissions
overwritePermissions(channel, role, options = {}, callback = (/*err*/) => { }) {
return this.internal.overwritePermissions(channel, role, options)
.then(callback, errCB(callback));
.then(callback, constructErrorCallback(callback));
}
//def setStatus
@@ -385,73 +385,73 @@ export default class Client extends EventEmitter {
}
return this.internal.setStatus(idleStatus, gameID)
.then(callback, errCB(callback));
.then(callback, constructErrorCallback(callback));
}
//def sendTyping
sendTyping(channel, callback = (/*err*/) => { }) {
return this.internal.sendTyping(channel)
.then(callback, errCB(callback));
.then(callback, constructErrorCallback(callback));
}
// def setTopic
setChannelTopic(channel, topic, callback = (/*err*/) => { }) {
return this.internal.setChannelTopic(channel, topic)
.then(callback, errCB(callback));
.then(callback, constructErrorCallback(callback));
}
//def setChannelName
setChannelName(channel, name, callback = (/*err*/) => { }) {
return this.internal.setChannelName(channel, name)
.then(callback, errCB(callback));
.then(callback, constructErrorCallback(callback));
}
//def setChannelNameAndTopic
setChannelNameAndTopic(channel, name, topic, callback = (/*err*/) => { }) {
return this.internal.setChannelNameAndTopic(channel, name, topic)
.then(callback, errCB(callback));
.then(callback, constructErrorCallback(callback));
}
//def setChannelPosition
setChannelPosition(channel, position, callback = (/*err*/) => { }) {
return this.internal.setChannelPosition(channel, position)
.then(callback, errCB(callback));
.then(callback, constructErrorCallback(callback));
}
//def updateChannel
updateChannel(channel, data, callback = (/*err*/) => { }) {
return this.internal.updateChannel(channel, data)
.then(callback, errCB(callback));
.then(callback, constructErrorCallback(callback));
}
//def startTyping
startTyping(channel, callback = (/*err*/) => { }) {
return this.internal.startTyping(channel)
.then(callback, errCB(callback));
.then(callback, constructErrorCallback(callback));
}
//def stopTyping
stopTyping(channel, callback = (/*err*/) => { }) {
return this.internal.stopTyping(channel)
.then(callback, errCB(callback));
.then(callback, constructErrorCallback(callback));
}
//def updateDetails
updateDetails(details, callback = (/*err*/) => { }) {
return this.internal.updateDetails(details)
.then(callback, errCB(callback));
.then(callback, constructErrorCallback(callback));
}
//def setUsername
setUsername(name, callback = (/*err*/) => { }) {
return this.internal.setUsername(name)
.then(callback, errCB(callback));
.then(callback, constructErrorCallback(callback));
}
//def setAvatar
setAvatar(avatar, callback = (/*err*/) => { }) {
return this.internal.setAvatar(avatar)
.then(callback, errCB(callback));
.then(callback, constructErrorCallback(callback));
}
//def joinVoiceChannel
@@ -460,13 +460,13 @@ export default class Client extends EventEmitter {
.then(chan => {
callback(null, chan);
return chan;
}, errCB(callback));
}, constructErrorCallback(callback));
}
// def leaveVoiceChannel
leaveVoiceChannel(callback = (/*err*/) => { }) {
return this.internal.leaveVoiceChannel()
.then(callback, errCB(callback));
.then(callback, constructErrorCallback(callback));
}
// def awaitResponse
@@ -504,17 +504,17 @@ export default class Client extends EventEmitter {
.then(newMsg => {
callback(null, newMsg);
return newMsg;
}, errCB(callback));
}, constructErrorCallback(callback));
}
setStatusIdle(callback = (/*err*/) => { }) {
return this.internal.setStatus("idle")
.then(callback, errCB(callback));
.then(callback, constructErrorCallback(callback));
}
setStatusOnline(callback = (/*err*/) => { }) {
return this.internal.setStatus("online")
.then(callback, errCB(callback));
.then(callback, constructErrorCallback(callback));
}
setStatusActive(callback) {