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 db = require("./DB").db;
|
||||
var async = require("async");
|
||||
var groupMangager = require("./GroupManager");
|
||||
|
@ -28,7 +29,8 @@ exports.doesSessionExist = function(sessionID, callback)
|
|||
//check if the database entry of this session exists
|
||||
db.get("session:" + sessionID, function (err, session)
|
||||
{
|
||||
callback(err, session != null);
|
||||
if(ERR(err, callback)) return;
|
||||
callback(null, session != null);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -45,13 +47,10 @@ exports.createSession = function(groupID, authorID, validUntil, callback)
|
|||
{
|
||||
groupMangager.doesGroupExist(groupID, function(err, exists)
|
||||
{
|
||||
//error
|
||||
if(err)
|
||||
{
|
||||
callback(err);
|
||||
}
|
||||
if(ERR(err, callback)) return;
|
||||
|
||||
//group does not exist
|
||||
else if(exists == false)
|
||||
if(exists == false)
|
||||
{
|
||||
callback({stop: "groupID does not exist"});
|
||||
}
|
||||
|
@ -67,13 +66,10 @@ exports.createSession = function(groupID, authorID, validUntil, callback)
|
|||
{
|
||||
authorMangager.doesAuthorExists(authorID, function(err, exists)
|
||||
{
|
||||
//error
|
||||
if(err)
|
||||
{
|
||||
callback(err);
|
||||
}
|
||||
if(ERR(err, callback)) return;
|
||||
|
||||
//author does not exist
|
||||
else if(exists == false)
|
||||
if(exists == false)
|
||||
{
|
||||
callback({stop: "authorID does not exist"});
|
||||
}
|
||||
|
@ -137,12 +133,7 @@ exports.createSession = function(groupID, authorID, validUntil, callback)
|
|||
//get the entry
|
||||
db.get("group2sessions:" + groupID, function(err, group2sessions)
|
||||
{
|
||||
//did a error happen?
|
||||
if(err)
|
||||
{
|
||||
callback(err);
|
||||
return;
|
||||
}
|
||||
if(ERR(err, callback)) return;
|
||||
|
||||
//the entry doesn't exist so far, let's create it
|
||||
if(group2sessions == null)
|
||||
|
@ -165,12 +156,7 @@ exports.createSession = function(groupID, authorID, validUntil, callback)
|
|||
//get the entry
|
||||
db.get("author2sessions:" + authorID, function(err, author2sessions)
|
||||
{
|
||||
//did a error happen?
|
||||
if(err)
|
||||
{
|
||||
callback(err);
|
||||
return;
|
||||
}
|
||||
if(ERR(err, callback)) return;
|
||||
|
||||
//the entry doesn't exist so far, let's create it
|
||||
if(author2sessions == null)
|
||||
|
@ -189,8 +175,10 @@ exports.createSession = function(groupID, authorID, validUntil, callback)
|
|||
}
|
||||
], function(err)
|
||||
{
|
||||
if(ERR(err, callback)) return;
|
||||
|
||||
//return error and sessionID
|
||||
callback(err, {sessionID: sessionID});
|
||||
callback(null, {sessionID: sessionID});
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -199,13 +187,10 @@ exports.getSessionInfo = function(sessionID, callback)
|
|||
//check if the database entry of this session exists
|
||||
db.get("session:" + sessionID, function (err, session)
|
||||
{
|
||||
//error
|
||||
if(err)
|
||||
{
|
||||
callback(err);
|
||||
}
|
||||
if(ERR(err, callback)) return;
|
||||
|
||||
//session does not exists
|
||||
else if(session == null)
|
||||
if(session == null)
|
||||
{
|
||||
callback({stop: "sessionID does not exist"})
|
||||
}
|
||||
|
@ -231,13 +216,10 @@ exports.deleteSession = function(sessionID, callback)
|
|||
//get the session entry
|
||||
db.get("session:" + sessionID, function (err, session)
|
||||
{
|
||||
//error
|
||||
if(err)
|
||||
{
|
||||
callback(err);
|
||||
}
|
||||
if(ERR(err, callback)) return;
|
||||
|
||||
//session does not exists
|
||||
else if(session == null)
|
||||
if(session == null)
|
||||
{
|
||||
callback({stop: "sessionID does not exist"})
|
||||
}
|
||||
|
@ -256,8 +238,9 @@ exports.deleteSession = function(sessionID, callback)
|
|||
{
|
||||
db.get("group2sessions:" + groupID, function (err, _group2sessions)
|
||||
{
|
||||
if(ERR(err, callback)) return;
|
||||
group2sessions = _group2sessions;
|
||||
callback(err);
|
||||
callback();
|
||||
});
|
||||
},
|
||||
//get the author2sessions entry
|
||||
|
@ -265,8 +248,9 @@ exports.deleteSession = function(sessionID, callback)
|
|||
{
|
||||
db.get("author2sessions:" + authorID, function (err, _author2sessions)
|
||||
{
|
||||
if(ERR(err, callback)) return;
|
||||
author2sessions = _author2sessions;
|
||||
callback(err);
|
||||
callback();
|
||||
});
|
||||
},
|
||||
//remove the values from the database
|
||||
|
@ -287,7 +271,8 @@ exports.deleteSession = function(sessionID, callback)
|
|||
}
|
||||
], function(err)
|
||||
{
|
||||
callback(err);
|
||||
if(ERR(err, callback)) return;
|
||||
callback();
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -295,13 +280,10 @@ exports.listSessionsOfGroup = function(groupID, callback)
|
|||
{
|
||||
groupMangager.doesGroupExist(groupID, function(err, exists)
|
||||
{
|
||||
//error
|
||||
if(err)
|
||||
{
|
||||
callback(err);
|
||||
}
|
||||
if(ERR(err, callback)) return;
|
||||
|
||||
//group does not exist
|
||||
else if(exists == false)
|
||||
if(exists == false)
|
||||
{
|
||||
callback({stop: "groupID does not exist"});
|
||||
}
|
||||
|
@ -317,13 +299,10 @@ exports.listSessionsOfAuthor = function(authorID, callback)
|
|||
{
|
||||
authorMangager.doesAuthorExists(authorID, function(err, exists)
|
||||
{
|
||||
//error
|
||||
if(err)
|
||||
{
|
||||
callback(err);
|
||||
}
|
||||
if(ERR(err, callback)) return;
|
||||
|
||||
//group does not exist
|
||||
else if(exists == false)
|
||||
if(exists == false)
|
||||
{
|
||||
callback({stop: "authorID does not exist"});
|
||||
}
|
||||
|
@ -346,8 +325,9 @@ function listSessionsWithDBKey (dbkey, callback)
|
|||
//get the group2sessions entry
|
||||
db.get(dbkey, function(err, sessionObject)
|
||||
{
|
||||
if(ERR(err, callback)) return;
|
||||
sessions = sessionObject ? sessionObject.sessionIDs : null;
|
||||
callback(err);
|
||||
callback();
|
||||
});
|
||||
},
|
||||
function(callback)
|
||||
|
@ -364,14 +344,16 @@ function listSessionsWithDBKey (dbkey, callback)
|
|||
{
|
||||
exports.getSessionInfo(sessionID, function(err, sessionInfo)
|
||||
{
|
||||
if(ERR(err, callback)) return;
|
||||
sessions[sessionID] = sessionInfo;
|
||||
callback(err);
|
||||
callback();
|
||||
});
|
||||
}, callback);
|
||||
}
|
||||
], function(err)
|
||||
{
|
||||
callback(err, sessions);
|
||||
if(ERR(err, callback)) return;
|
||||
callback(null, sessions);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue