Skip to content

Commit 3da2840

Browse files
committed
Overkill logging.
1 parent 309a7e6 commit 3da2840

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

backend/server/controllers/courseinstances.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ const Checklist = require('../models').Checklist
1515
const env = process.env.NODE_ENV || 'development'
1616
const config = require('./../config/config.js')[env]
1717

18+
const overkillLogging = (req, error) => {
19+
console.log('request: ', req)
20+
console.log('error: ', error)
21+
}
22+
1823
module.exports = {
1924
/**
2025
*
@@ -265,31 +270,36 @@ module.exports = {
265270
}
266271
})
267272
if (!course) {
273+
overkillLogging(req, null)
268274
return res.status(400).send({
269275
message: 'course instance not found'
270276
})
271277
}
272278
if (course.active === false) {
273279
console.log('course is not active')
280+
overkillLogging(req, null)
274281
return res.status(400).send({
275282
message: 'course is not active'
276283
})
277284
}
278285
const user = await User.findById(req.decoded.id)
279286
if (!user) {
287+
overkillLogging(req, null)
280288
return res.status(400).send({
281-
message: 'something went wrong (clear these specific error messages later): user not found'
289+
message: 'User could not be found.'
282290
})
283291
}
284292
const webOodiStatus = await new Promise((resolve) => {
285293
helper.checkWebOodi(req, res, user, resolve) // this does not work.
286294

287295
setTimeout(function() {
296+
overkillLogging(req, null)
288297
resolve('shitaintright') // Yay! everything went to hell.
289298
}, 5000) // set a high timeout value since you really want to wait x)
290299
})
291300

292301
if (webOodiStatus !== 'found') {
302+
overkillLogging(req, null)
293303
return res.status(403).json({
294304
message: 'You have not yet registered to this course at WebOodi. If you have already registered at WebOodi, try again in two hours.'
295305
})
@@ -320,12 +330,13 @@ module.exports = {
320330
message: errorMessage.join('\n')
321331
})
322332
}
323-
console.log('Unexpected error in registration.', error)
333+
overkillLogging(req, error)
324334
return res.status(500).json({
325335
message: 'Unexpected error.'
326336
})
327337
}
328338
if (!student) {
339+
overkillLogging(req, null)
329340
res.status(400).json({
330341
message: 'Student record could not be found or created.'
331342
})

backend/server/helpers/course_instance_helper.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ function checkWebOodi(req, res, user, resolve) {
4646
return
4747
} else {
4848
console.log('\ncourse_instance_helper notfound')
49-
console.info(json.students)
50-
console.info(user.studentNumber)
49+
console.info(json)
50+
console.info('studentNumber:', user.studentNumber)
5151
resolve('notfound')
5252
return
5353
}

0 commit comments

Comments
 (0)