Handle a couple errors I saw in the logs

This commit is contained in:
Nick Winter 2016-05-08 10:05:26 -07:00
parent 4172f03fad
commit d0be5c1f22
3 changed files with 10 additions and 2 deletions

1
.gitignore vendored
View file

@ -104,3 +104,4 @@ Dockerfile
# coffeelint for editors (might be standardized eventually) # coffeelint for editors (might be standardized eventually)
coffeelint.json coffeelint.json
gitSpy/*

View file

@ -18,7 +18,14 @@ PatchSchema.pre 'save', (next) ->
return next(err) return next(err)
collection = target.collection collection = target.collection
handler = require('../' + handlers[collection]) try
handler = require('../' + handlers[collection])
catch err
console.error 'Couldn\'t find handler for collection:', target.collection, 'from target', target
err = new Error('Server error.')
err.response = {message: '', property: 'target.id'}
err.code = 500
return next(err)
handler.getDocumentForIdOrSlug targetID, (err, document) => handler.getDocumentForIdOrSlug targetID, (err, document) =>
if err if err
err = new Error('Server error.') err = new Error('Server error.')

View file

@ -30,7 +30,7 @@ module.exports.sendResponseObject = (res, object) ->
module.exports.formatSessionInformation = (session) -> module.exports.formatSessionInformation = (session) ->
heroID = if session.team is 'ogres' then 'hero-placeholder-1' else 'hero-placeholder' heroID = if session.team is 'ogres' then 'hero-placeholder-1' else 'hero-placeholder'
submittedCode = {} submittedCode = {}
submittedCode[heroID] = plan: LZString.compressToUTF16 session.submittedCode[heroID].plan submittedCode[heroID] = plan: LZString.compressToUTF16(session.submittedCode[heroID]?.plan ? '')
_id: session._id _id: session._id
sessionID: session._id sessionID: session._id