mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 14:13:43 +01:00
Be more specific about the source-file-not-found error case
This commit is contained in:
@@ -32,12 +32,12 @@ BadDataError = (message) ->
|
||||
BadDataError.prototype.__proto__ = Error.prototype
|
||||
|
||||
|
||||
FileNotFoundError = (message) ->
|
||||
SourceFileNotFoundError = (message) ->
|
||||
error = new Error(message)
|
||||
error.name = 'BadData'
|
||||
error.__proto__ = FileNotFoundError.prototype
|
||||
error.__proto__ = SourceFileNotFoundError.prototype
|
||||
return error
|
||||
FileNotFoundError.prototype.__proto__ = Error.prototype
|
||||
SourceFileNotFoundError.prototype.__proto__ = Error.prototype
|
||||
|
||||
|
||||
module.exports = ProjectFileAgent =
|
||||
@@ -68,7 +68,7 @@ module.exports = ProjectFileAgent =
|
||||
}, (err, entity, type) ->
|
||||
if err?
|
||||
if err.toString().match(/^not found.*/)
|
||||
err = new FileNotFoundError()
|
||||
err = new SourceFileNotFoundError()
|
||||
return callback(err)
|
||||
ProjectFileAgent._writeEntityToDisk source_project_id, entity._id, type, callback
|
||||
|
||||
@@ -92,8 +92,8 @@ module.exports = ProjectFileAgent =
|
||||
res.status(400).send("The submitted data is not valid")
|
||||
else if error instanceof BadEntityTypeError
|
||||
res.status(400).send("The file is the wrong type")
|
||||
else if error instanceof FileNotFoundError
|
||||
res.status(404).send("File not found")
|
||||
else if error instanceof SourceFileNotFoundError
|
||||
res.status(404).send("Source file not found")
|
||||
else
|
||||
next(error)
|
||||
next()
|
||||
|
||||
Reference in New Issue
Block a user