@@ -15,6 +15,11 @@ const Checklist = require('../models').Checklist
1515const env = process . env . NODE_ENV || 'development'
1616const config = require ( './../config/config.js' ) [ env ]
1717
18+ const overkillLogging = ( req , error ) => {
19+ console . log ( 'request: ' , req )
20+ console . log ( 'error: ' , error )
21+ }
22+
1823module . 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 } )
0 commit comments