Skip to content

Commit

Permalink
refactor(edit-logs): intercept unexpected errors
Browse files Browse the repository at this point in the history
  • Loading branch information
naholyr committed Sep 8, 2017
1 parent 7f9530c commit 654c905
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions server/routes/editLog.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'

const { Router } = require('express')
const { UnauthorizedError, NotFoundError } = require('../lib/errors')
const { UnauthorizedError, NotFoundError, ServerError } = require('../lib/errors')
const { EditLog, flattenDiff } = require('../lib/edit-logs')
const { requiresAuthentication, scopeOrganizationMiddleware } = require('../lib/permissions')
const models = require('../lib/model')
Expand Down Expand Up @@ -251,7 +251,12 @@ function getEditLog(req, res){

return editsP
.then(edits => res.status(200).send(edits))
.catch(err => res.status(err.status || 500).send(err))
.catch(err => {
if (!err.status) {
err = new ServerError({ title: err.message })
}
res.status(err.status).send(err)
})
}

function formatItemName(data, model){
Expand Down

0 comments on commit 654c905

Please sign in to comment.