changes regarding error handling
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
tsUtils = require("../lib/utils");
|
||||
const path = require('path')
|
||||
const path = require('path');
|
||||
const { teamsnapFailure, tsPromise } = require("../lib/utils");
|
||||
|
||||
|
||||
exports.helpers = {
|
||||
@@ -23,7 +24,7 @@ exports.getEvents = async (req, res, next) => {
|
||||
const {user, team, layout} = req
|
||||
const bulkLoadTypes = ["event", "availabilitySummary"]
|
||||
req.promises.push(
|
||||
teamsnap.bulkLoad(team.id, bulkLoadTypes , () => {tsUtils.teamsnapCallback;req.items = tsUtils.teamsnapLog('bulkLoad', types=bulkLoadTypes, team.id, req)})
|
||||
tsPromise('bulkLoad', {teamId: team.id, types: bulkLoadTypes})
|
||||
.then(items=>tsUtils.groupTeamsnapItems(items))
|
||||
.then(items=>{
|
||||
items.events.forEach((event) => {
|
||||
@@ -31,16 +32,25 @@ exports.getEvents = async (req, res, next) => {
|
||||
}
|
||||
)
|
||||
req.events = items.events;
|
||||
}
|
||||
)
|
||||
}
|
||||
)
|
||||
.then(tsUtils.teamsnapLog('bulkLoad', types=bulkLoadTypes, team.id, req))
|
||||
.catch((err) => {
|
||||
teamsnapFailure(err,next)
|
||||
})
|
||||
)
|
||||
await Promise.all(req.promises)
|
||||
const context = {
|
||||
title: "Events",
|
||||
user, team, layout,
|
||||
events: req.events,
|
||||
};
|
||||
res.render("event/list", context);
|
||||
|
||||
try {
|
||||
const context = {
|
||||
title: "Events",
|
||||
user, team, layout,
|
||||
events: req.events,
|
||||
};
|
||||
res.render("event/list", context);
|
||||
} catch(e) {
|
||||
next(e)
|
||||
}
|
||||
};
|
||||
|
||||
exports.getEvent = async (req, res, next) => {
|
||||
|
||||
Reference in New Issue
Block a user