Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
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
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
b8120886
Commit
b8120886
authored
9 years ago
by
Cam Saül
Committed by
Arthur Ulfeldt
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
handle exceptions
parent
5d1cf651
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/metabase/routes.clj
+12
-2
12 additions, 2 deletions
src/metabase/routes.clj
with
12 additions
and
2 deletions
src/metabase/routes.clj
+
12
−
2
View file @
b8120886
...
...
@@ -53,6 +53,9 @@
(
Thread/sleep
30000
)
{
:success
true
})
(
defn-
some-naughty-handler-that-barfs
[
_
]
(
throw
(
Exception.
"BARF!"
)))
(
def
^
:private
^
:const
streaming-response-keep-alive-interval-ms
"Interval between sending whitespace bytes to keep Heroku from terminating
requests like queries that take a long time to complete."
...
...
@@ -60,9 +63,14 @@
(
defn-
streaming-response
[
handler
]
(
fn
[
request
]
;; TODO - handle exceptions & have some sort of maximum timeout for these requests
;; TODO - need maximum timeout for requests
;; TODO - error response should have status code != 200 (how ?)
;; TODO - handle exceptions in JSON encoding as well
(
->
(
fn
[
^
java.io.PipedOutputStream
ostream
]
(
let
[
response
(
future
(
handler
request
))
(
let
[
response
(
future
(
try
(
handler
request
)
(
catch
Throwable
e
{
:error
(
.getMessage
e
)
:stacktrace
(
u/filtered-stacktrace
e
)})))
write-response
(
future
(
json/generate-stream
@
response
(
io/writer
ostream
))
(
println
"Done! closing ostream..."
)
(
.close
ostream
))]
...
...
@@ -103,5 +111,7 @@
(
context
"/embed"
[]
embed-routes
)
(
context
"/stream-test"
[]
(
streaming-response
some-very-long-handler
))
(
context
"/stream-test-2"
[]
(
streaming-response
some-naughty-handler-that-barfs
))
;; Anything else (e.g. /user/edit_current) should serve up index.html; React app will handle the rest
(
GET
"*"
[]
index
))
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