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
d0bd31dd
Commit
d0bd31dd
authored
7 years ago
by
Cam Saül
Browse files
Options
Downloads
Patches
Plain Diff
Change 404 response format for archive objects so frontend can parse
more easily
parent
7400b720
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/api/common.clj
+8
-3
8 additions, 3 deletions
src/metabase/api/common.clj
with
8 additions
and
3 deletions
src/metabase/api/common.clj
+
8
−
3
View file @
d0bd31dd
...
...
@@ -40,6 +40,8 @@
"Assertion mechanism for use inside API functions.
Checks that TEST is true, or throws an `ExceptionInfo` with STATUS-CODE and MESSAGE.
MESSAGE can be either a plain string error message, or a map including the key `:message` and any additional details, such as an `:error_code`.
This exception is automatically caught in the body of `defendpoint` functions, and the appropriate HTTP response is generated.
`check` can be called with the form
...
...
@@ -59,7 +61,9 @@
[
code-or-code-message-pair
rest-args
]
[[
code-or-code-message-pair
(
first
rest-args
)]
(
rest
rest-args
)])]
(
when-not
tst
(
throw
(
ex-info
message
{
:status-code
code
})))
(
throw
(
if
(
map?
message
)
(
ex-info
(
:message
message
)
(
assoc
message
:status-code
code
))
(
ex-info
message
{
:status-code
code
}))))
(
if
(
empty?
rest-args
)
tst
(
recur
(
first
rest-args
)
(
second
rest-args
)
(
drop
2
rest-args
))))))
...
...
@@ -313,8 +317,9 @@
[
400
"Embedding is not enabled."
]))
(
defn
check-not-archived
"Check that the OBJECT is not `:archived`, or throw a `404`. Returns OBJECT as-is if check passes."
"Check that the OBJECT
exists and
is not `:archived`, or throw a `404`. Returns OBJECT as-is if check passes."
[
object
]
(
u/prog1
object
(
check-404
object
)
(
check
(
not
(
:archived
object
))
[
404
"The object has been archived."
])))
[
404
{
:message
"The object has been archived."
,
:error_code
"archived"
}
])))
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