mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-20 23:46:14 -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 padManager = require("./PadManager");
|
||||
|
@ -34,13 +35,10 @@ exports.deleteGroup = function(groupID, callback)
|
|||
//try to get the group entry
|
||||
db.get("group:" + groupID, function (err, _group)
|
||||
{
|
||||
//error
|
||||
if(err)
|
||||
{
|
||||
callback(err);
|
||||
}
|
||||
if(ERR(err, callback)) return;
|
||||
|
||||
//group does not exist
|
||||
else if(_group == null)
|
||||
if(_group == null)
|
||||
{
|
||||
callback({stop: "groupID does not exist"});
|
||||
}
|
||||
|
@ -67,7 +65,7 @@ exports.deleteGroup = function(groupID, callback)
|
|||
{
|
||||
padManager.getPad(padID, function(err, pad)
|
||||
{
|
||||
if(err) {callback(err); return}
|
||||
if(ERR(err, callback)) return;
|
||||
|
||||
pad.remove(callback);
|
||||
});
|
||||
|
@ -79,7 +77,7 @@ exports.deleteGroup = function(groupID, callback)
|
|||
//try to get the group entry
|
||||
db.get("group2sessions:" + groupID, function (err, group2sessions)
|
||||
{
|
||||
if(err) {callback(err); return}
|
||||
if(ERR(err, callback)) return;
|
||||
|
||||
//skip if there is no group2sessions entry
|
||||
if(group2sessions == null) {callback(); return}
|
||||
|
@ -107,7 +105,8 @@ exports.deleteGroup = function(groupID, callback)
|
|||
}
|
||||
], function(err)
|
||||
{
|
||||
callback(err);
|
||||
if(ERR(err, callback)) return;
|
||||
callback();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -116,7 +115,8 @@ exports.doesGroupExist = function(groupID, callback)
|
|||
//try to get the group entry
|
||||
db.get("group:" + groupID, function (err, group)
|
||||
{
|
||||
callback(err, group != null);
|
||||
if(ERR(err, callback)) return;
|
||||
callback(null, group != null);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -142,23 +142,14 @@ exports.createGroupIfNotExistsFor = function(groupMapper, callback)
|
|||
//try to get a group for this mapper
|
||||
db.get("mapper2group:"+groupMapper, function(err, groupID)
|
||||
{
|
||||
if(err)
|
||||
{
|
||||
callback(err);
|
||||
return;
|
||||
}
|
||||
if(ERR(err, callback)) return;
|
||||
|
||||
//there is no group for this mapper, let's create a group
|
||||
if(groupID == null)
|
||||
{
|
||||
exports.createGroup(function(err, responseObj)
|
||||
{
|
||||
//check for errors
|
||||
if(err)
|
||||
{
|
||||
callback(err);
|
||||
return;
|
||||
}
|
||||
if(ERR(err, callback)) return;
|
||||
|
||||
//create the mapper entry for this group
|
||||
db.set("mapper2group:"+groupMapper, responseObj.groupID);
|
||||
|
@ -169,7 +160,8 @@ exports.createGroupIfNotExistsFor = function(groupMapper, callback)
|
|||
//there is a group for this mapper, let's return it
|
||||
else
|
||||
{
|
||||
callback(err, {groupID: groupID});
|
||||
if(ERR(err, callback)) return;
|
||||
callback(null, {groupID: groupID});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -185,13 +177,10 @@ exports.createGroupPad = function(groupID, padName, text, callback)
|
|||
{
|
||||
exports.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"});
|
||||
}
|
||||
|
@ -207,13 +196,10 @@ exports.createGroupPad = function(groupID, padName, text, callback)
|
|||
{
|
||||
padManager.doesPadExists(padID, function(err, exists)
|
||||
{
|
||||
//error
|
||||
if(err)
|
||||
{
|
||||
callback(err);
|
||||
}
|
||||
if(ERR(err, callback)) return;
|
||||
|
||||
//pad exists already
|
||||
else if(exists == true)
|
||||
if(exists == true)
|
||||
{
|
||||
callback({stop: "padName does already exist"});
|
||||
}
|
||||
|
@ -229,7 +215,8 @@ exports.createGroupPad = function(groupID, padName, text, callback)
|
|||
{
|
||||
padManager.getPad(padID, text, function(err)
|
||||
{
|
||||
callback(err);
|
||||
if(ERR(err, callback)) return;
|
||||
callback();
|
||||
});
|
||||
},
|
||||
//create an entry in the group for this pad
|
||||
|
@ -240,7 +227,8 @@ exports.createGroupPad = function(groupID, padName, text, callback)
|
|||
}
|
||||
], function(err)
|
||||
{
|
||||
callback(err, {padID: padID});
|
||||
if(ERR(err, callback)) return;
|
||||
callback(null, {padID: padID});
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -248,13 +236,10 @@ exports.listPads = function(groupID, callback)
|
|||
{
|
||||
exports.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"});
|
||||
}
|
||||
|
@ -263,7 +248,8 @@ exports.listPads = function(groupID, callback)
|
|||
{
|
||||
db.getSub("group:" + groupID, ["pads"], function(err, pads)
|
||||
{
|
||||
callback(err, {padIDs: pads});
|
||||
if(ERR(err, callback)) return;
|
||||
callback(null, {padIDs: pads});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue