Skip to content
Snippets Groups Projects
Verified Commit 70bd3baf authored by Shane Kilkelly's avatar Shane Kilkelly Committed by David Mehren
Browse files

Use errors from ProjectFileAgent

parent 8e0b1149
Branches
No related tags found
No related merge requests found
...@@ -58,9 +58,12 @@ SourceFileNotFoundError = (message) -> ...@@ -58,9 +58,12 @@ SourceFileNotFoundError = (message) ->
SourceFileNotFoundError.prototype.__proto__ = Error.prototype SourceFileNotFoundError.prototype.__proto__ = Error.prototype
module.exports = ProjectFileAgent = module.exports = ProjectFileAgent = {
V1ProjectNotFoundError: V1ProjectNotFoundError V1ProjectNotFoundError
BadDataError
ProjectNotFoundError
V1ProjectNotFoundError
_v1ProjectNotFoundMessage: "Sorry, the source project is not yet imported to Overleaf v2. Please import it to Overleaf v2 to refresh this file" _v1ProjectNotFoundMessage: "Sorry, the source project is not yet imported to Overleaf v2. Please import it to Overleaf v2 to refresh this file"
...@@ -163,3 +166,4 @@ module.exports = ProjectFileAgent = ...@@ -163,3 +166,4 @@ module.exports = ProjectFileAgent =
else else
next(error) next(error)
next() next()
}
...@@ -11,22 +11,6 @@ _ = require "underscore" ...@@ -11,22 +11,6 @@ _ = require "underscore"
request = require "request" request = require "request"
BadDataError = (message) ->
error = new Error(message)
error.name = 'BadData'
error.__proto__ = BadDataError.prototype
return error
BadDataError.prototype.__proto__ = Error.prototype
ProjectNotFoundError = (message) ->
error = new Error(message)
error.name = 'ProjectNotFound'
error.__proto__ = ProjectNotFoundError.prototype
return error
ProjectNotFoundError.prototype.__proto__ = Error.prototype
OutputFileFetchFailedError = (message) -> OutputFileFetchFailedError = (message) ->
error = new Error(message) error = new Error(message)
error.name = 'OutputFileFetchFailedError' error.name = 'OutputFileFetchFailedError'
...@@ -92,11 +76,11 @@ module.exports = ProjectOutputFileAgent = { ...@@ -92,11 +76,11 @@ module.exports = ProjectOutputFileAgent = {
callback(error) callback(error)
handleError: (error, req, res, next) -> handleError: (error, req, res, next) ->
if error instanceof BadDataError if error instanceof ProjectFileAgent.BadDataError
res.status(400).send("The submitted data is not valid") res.status(400).send("The submitted data is not valid")
else if error instanceof OutputFileFetchFailedError else if error instanceof OutputFileFetchFailedError
res.status(404).send("Could not get output file") res.status(404).send("Could not get output file")
else if error instanceof ProjectNotFoundError else if error instanceof ProjectFileAgent.ProjectNotFoundError
res.status(404).send("Project not found") res.status(404).send("Project not found")
else if error instanceof ProjectFileAgent.V1ProjectNotFoundError else if error instanceof ProjectFileAgent.V1ProjectNotFoundError
res.status(409).send(ProjectFileAgent._v1ProjectNotFoundMessage) res.status(409).send(ProjectFileAgent._v1ProjectNotFoundMessage)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment