mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-20 15:36:16 -04:00
Changed all error handling to async-stacktrace style + fixed import/export on unix
This commit is contained in:
parent
db1ba6a65e
commit
5c56e62d67
18 changed files with 325 additions and 352 deletions
|
@ -18,6 +18,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
var ERR = require("async-stacktrace");
|
||||
var async = require("async");
|
||||
var padManager = require("../db/PadManager");
|
||||
var Changeset = require("../utils/Changeset");
|
||||
|
@ -107,7 +108,7 @@ exports.handleDisconnect = function(client)
|
|||
//get the author color out of the db
|
||||
authorManager.getAuthorColorId(author, function(err, color)
|
||||
{
|
||||
if(err) throw err;
|
||||
ERR(err);
|
||||
|
||||
//prepare the notification for the other users on the pad, that this user left
|
||||
var messageToTheOtherUsers = {
|
||||
|
@ -218,16 +219,18 @@ function handleChatMessage(client, message)
|
|||
{
|
||||
padManager.getPad(padId, function(err, _pad)
|
||||
{
|
||||
if(ERR(err, callback)) return;
|
||||
pad = _pad;
|
||||
callback(err);
|
||||
callback();
|
||||
});
|
||||
},
|
||||
function(callback)
|
||||
{
|
||||
authorManager.getAuthorName(userId, function(err, _userName)
|
||||
{
|
||||
if(ERR(err, callback)) return;
|
||||
userName = _userName;
|
||||
callback(err);
|
||||
callback();
|
||||
});
|
||||
},
|
||||
//save the chat message and broadcast it
|
||||
|
@ -257,7 +260,7 @@ function handleChatMessage(client, message)
|
|||
}
|
||||
], function(err)
|
||||
{
|
||||
if(err) throw err;
|
||||
ERR(err);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -375,8 +378,9 @@ function handleUserChanges(client, message)
|
|||
{
|
||||
padManager.getPad(session2pad[client.id], function(err, value)
|
||||
{
|
||||
if(ERR(err, callback)) return;
|
||||
pad = value;
|
||||
callback(err);
|
||||
callback();
|
||||
});
|
||||
},
|
||||
//create the changeset
|
||||
|
@ -422,16 +426,10 @@ function handleUserChanges(client, message)
|
|||
|
||||
pad.getRevisionChangeset(r, function(err, c)
|
||||
{
|
||||
if(err)
|
||||
{
|
||||
callback(err);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
changeset = Changeset.follow(c, changeset, false, apool);
|
||||
callback(null);
|
||||
}
|
||||
if(ERR(err, callback)) return;
|
||||
|
||||
changeset = Changeset.follow(c, changeset, false, apool);
|
||||
callback(null);
|
||||
});
|
||||
},
|
||||
//use the callback of the series function
|
||||
|
@ -469,7 +467,7 @@ function handleUserChanges(client, message)
|
|||
}
|
||||
], function(err)
|
||||
{
|
||||
if(err) throw err;
|
||||
ERR(err);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -502,25 +500,23 @@ exports.updatePadClients = function(pad, callback)
|
|||
{
|
||||
pad.getRevisionAuthor(r, function(err, value)
|
||||
{
|
||||
if(ERR(err, callback)) return;
|
||||
author = value;
|
||||
callback(err);
|
||||
callback();
|
||||
});
|
||||
},
|
||||
function (callback)
|
||||
{
|
||||
pad.getRevisionChangeset(r, function(err, value)
|
||||
{
|
||||
if(ERR(err, callback)) return;
|
||||
revChangeset = value;
|
||||
callback(err);
|
||||
callback();
|
||||
});
|
||||
}
|
||||
], function(err)
|
||||
{
|
||||
if(err)
|
||||
{
|
||||
callback(err);
|
||||
return;
|
||||
}
|
||||
if(ERR(err, callback)) return;
|
||||
|
||||
if(author == sessioninfos[session].author)
|
||||
{
|
||||
|
@ -633,7 +629,7 @@ function handleClientReady(client, message)
|
|||
{
|
||||
securityManager.checkAccess (message.padId, message.sessionID, message.token, message.password, function(err, statusObject)
|
||||
{
|
||||
if(err) {callback(err); return}
|
||||
if(ERR(err, callback)) return;
|
||||
|
||||
//access was granted
|
||||
if(statusObject.accessStatus == "grant")
|
||||
|
@ -657,8 +653,9 @@ function handleClientReady(client, message)
|
|||
{
|
||||
authorManager.getAuthorColorId(author, function(err, value)
|
||||
{
|
||||
if(ERR(err, callback)) return;
|
||||
authorColorId = value;
|
||||
callback(err);
|
||||
callback();
|
||||
});
|
||||
},
|
||||
//get author name
|
||||
|
@ -666,24 +663,27 @@ function handleClientReady(client, message)
|
|||
{
|
||||
authorManager.getAuthorName(author, function(err, value)
|
||||
{
|
||||
if(ERR(err, callback)) return;
|
||||
authorName = value;
|
||||
callback(err);
|
||||
callback();
|
||||
});
|
||||
},
|
||||
function(callback)
|
||||
{
|
||||
padManager.getPad(message.padId, function(err, value)
|
||||
{
|
||||
if(ERR(err, callback)) return;
|
||||
pad = value;
|
||||
callback(err);
|
||||
callback();
|
||||
});
|
||||
},
|
||||
function(callback)
|
||||
{
|
||||
readOnlyManager.getReadOnlyId(message.padId, function(err, value)
|
||||
{
|
||||
if(ERR(err, callback)) return;
|
||||
readOnlyId = value;
|
||||
callback(err);
|
||||
callback();
|
||||
});
|
||||
}
|
||||
], callback);
|
||||
|
@ -701,9 +701,10 @@ function handleClientReady(client, message)
|
|||
{
|
||||
authorManager.getAuthor(authorId, function(err, author)
|
||||
{
|
||||
if(ERR(err, callback)) return;
|
||||
delete author.timestamp;
|
||||
historicalAuthorData[authorId] = author;
|
||||
callback(err);
|
||||
callback();
|
||||
});
|
||||
}, callback);
|
||||
},
|
||||
|
@ -712,8 +713,9 @@ function handleClientReady(client, message)
|
|||
{
|
||||
pad.getLastChatMessages(100, function(err, _chatMessages)
|
||||
{
|
||||
if(ERR(err, callback)) return;
|
||||
chatMessages = _chatMessages;
|
||||
callback(err);
|
||||
callback();
|
||||
});
|
||||
}
|
||||
], callback);
|
||||
|
@ -859,16 +861,18 @@ function handleClientReady(client, message)
|
|||
{
|
||||
authorManager.getAuthorColorId(sessioninfos[sessionID].author, function(err, value)
|
||||
{
|
||||
if(ERR(err, callback)) return;
|
||||
sessionAuthorColorId = value;
|
||||
callback(err);
|
||||
callback();
|
||||
})
|
||||
},
|
||||
function(callback)
|
||||
{
|
||||
authorManager.getAuthorName(sessioninfos[sessionID].author, function(err, value)
|
||||
{
|
||||
if(ERR(err, callback)) return;
|
||||
sessionAuthorName = value;
|
||||
callback(err);
|
||||
callback();
|
||||
})
|
||||
}
|
||||
],callback);
|
||||
|
@ -903,6 +907,6 @@ function handleClientReady(client, message)
|
|||
}
|
||||
],function(err)
|
||||
{
|
||||
if(err) throw err;
|
||||
ERR(err);
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue