Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
texjs-web
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
David Mehren
texjs-web
Commits
a8b32813
Verified
Commit
a8b32813
authored
7 years ago
by
Shane Kilkelly
Committed by
David Mehren
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Move the `handleError` function into the `LinkedFilesController`
parent
ba5db034
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/coffee/Features/LinkedFiles/LinkedFilesController.coffee
+52
-4
52 additions, 4 deletions
app/coffee/Features/LinkedFiles/LinkedFilesController.coffee
app/coffee/Features/LinkedFiles/LinkedFilesErrors.coffee
+0
-38
0 additions, 38 deletions
app/coffee/Features/LinkedFiles/LinkedFilesErrors.coffee
with
52 additions
and
42 deletions
app/coffee/Features/LinkedFiles/LinkedFilesController.coffee
+
52
−
4
View file @
a8b32813
...
...
@@ -4,8 +4,19 @@ ProjectLocator = require '../Project/ProjectLocator'
Settings
=
require
'settings-sharelatex'
logger
=
require
'logger-sharelatex'
_
=
require
'underscore'
LinkedFilesErrors
=
require
'./LinkedFilesErrors'
LinkedFilesHandler
=
require
'./LinkedFilesHandler'
{
UrlFetchFailedError
,
InvalidUrlError
,
OutputFileFetchFailedError
,
AccessDeniedError
,
BadEntityTypeError
,
BadDataError
,
ProjectNotFoundError
,
V1ProjectNotFoundError
,
SourceFileNotFoundError
,
}
=
require
'./LinkedFilesErrors'
module
.
exports
=
LinkedFilesController
=
{
...
...
@@ -41,7 +52,7 @@ module.exports = LinkedFilesController = {
parent_folder_id
,
user_id
,
(
err
,
newFileId
)
->
return
LinkedFiles
Errors
.
handleError
(
err
,
req
,
res
,
next
)
if
err
?
return
LinkedFiles
Controller
.
handleError
(
err
,
req
,
res
,
next
)
if
err
?
res
.
json
(
new_file_id
:
newFileId
)
refreshLinkedFile
:
(
req
,
res
,
next
)
->
...
...
@@ -68,7 +79,44 @@ module.exports = LinkedFilesController = {
parent_folder_id
,
user_id
,
(
err
,
newFileId
)
->
return
LinkedFiles
Errors
.
handleError
(
err
,
req
,
res
,
next
)
if
err
?
return
LinkedFiles
Controller
.
handleError
(
err
,
req
,
res
,
next
)
if
err
?
res
.
json
(
new_file_id
:
newFileId
)
handleError
:
(
error
,
req
,
res
,
next
)
->
if
error
instanceof
BadDataError
res
.
status
(
400
).
send
(
"The submitted data is not valid"
)
else
if
error
instanceof
AccessDeniedError
res
.
status
(
403
).
send
(
"You do not have access to this project"
)
else
if
error
instanceof
BadDataError
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
SourceFileNotFoundError
res
.
status
(
404
).
send
(
"Source file not found"
)
else
if
error
instanceof
ProjectNotFoundError
res
.
status
(
404
).
send
(
"Project not found"
)
else
if
error
instanceof
V1ProjectNotFoundError
res
.
status
(
409
).
send
(
"Sorry, the source project is not yet imported to Overleaf v2. Please import it to Overleaf v2 to refresh this file"
)
else
if
error
instanceof
OutputFileFetchFailedError
res
.
status
(
404
).
send
(
"Could not get output file"
)
else
if
error
instanceof
UrlFetchFailedError
res
.
status
(
422
).
send
(
"Your URL could not be reached (
#{
error
.
statusCode
}
status code). Please check it and try again."
)
else
if
error
instanceof
InvalidUrlError
res
.
status
(
422
).
send
(
"Your URL is not valid. Please check it and try again."
)
else
next
(
error
)
}
This diff is collapsed.
Click to expand it.
app/coffee/Features/LinkedFiles/LinkedFilesErrors.coffee
+
0
−
38
View file @
a8b32813
...
...
@@ -81,42 +81,4 @@ module.exports = {
ProjectNotFoundError
,
V1ProjectNotFoundError
,
SourceFileNotFoundError
,
handleError
:
(
error
,
req
,
res
,
next
)
->
if
error
instanceof
BadDataError
res
.
status
(
400
).
send
(
"The submitted data is not valid"
)
else
if
error
instanceof
AccessDeniedError
res
.
status
(
403
).
send
(
"You do not have access to this project"
)
else
if
error
instanceof
BadDataError
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
SourceFileNotFoundError
res
.
status
(
404
).
send
(
"Source file not found"
)
else
if
error
instanceof
ProjectNotFoundError
res
.
status
(
404
).
send
(
"Project not found"
)
else
if
error
instanceof
V1ProjectNotFoundError
res
.
status
(
409
).
send
(
"Sorry, the source project is not yet imported to Overleaf v2. Please import it to Overleaf v2 to refresh this file"
)
else
if
error
instanceof
OutputFileFetchFailedError
res
.
status
(
404
).
send
(
"Could not get output file"
)
else
if
error
instanceof
UrlFetchFailedError
res
.
status
(
422
).
send
(
"Your URL could not be reached (
#{
error
.
statusCode
}
status code). Please check it and try again."
)
else
if
error
instanceof
InvalidUrlError
res
.
status
(
422
).
send
(
"Your URL is not valid. Please check it and try again."
)
else
next
(
error
)
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment