Skip to content

Commit 5aa7945

Browse files
committed
move, for ordering reasons
1 parent 6fd4f68 commit 5aa7945

File tree

2 files changed

+25
-25
lines changed

2 files changed

+25
-25
lines changed

src/restapi.jl

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,31 @@ function _parse_response_json(r::_RESTResponse, ::Type{T})::Tuple{T, String} whe
7979
return _parse_response_json(r.body, T)
8080
end
8181

82+
# Check that the API response is not a legacy 200 internal error, where
83+
# we return
84+
#
85+
# {"success": false, "interal_error": true, "message": "..."}
86+
#
87+
# on internal errors. If it detects that this is an internal error, it throws
88+
# a JuliaHubError. Returns `nothing` otherwise.
89+
function _check_internal_error(r::_RESTResponse; var::AbstractString)
90+
if !(r.status == 200)
91+
return nothing
92+
end
93+
success = _get_json_or(r.json, "success", Any, nothing)
94+
internal_error = _get_json_or(r.json, "internal_error", Any, nothing)
95+
if (success === false) && (internal_error === true)
96+
e = JuliaHubError(
97+
"""
98+
Internal Server Error 200 response from JuliaHub ($var):
99+
JSON: $(sprint(show, MIME("text/plain"), r.json))
100+
""",
101+
)
102+
throw(e)
103+
end
104+
return nothing
105+
end
106+
82107
# _restcall calls _rest_request_mockable which calls _rest_request_http. The reason for this
83108
# indirection is that the signature of _rest_request_mockable is extremely simple and therefore
84109
# each to hook into with Mockable.

src/utils.jl

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -361,31 +361,6 @@ function _json_check_success(json::Dict; var::AbstractString)
361361
return nothing
362362
end
363363

364-
# Check that the API response is not a legacy 200 internal error, where
365-
# we return
366-
#
367-
# {"success": false, "interal_error": true, "message": "..."}
368-
#
369-
# on internal errors. If it detects that this is an internal error, it throws
370-
# a JuliaHubError. Returns `nothing` otherwise.
371-
function _check_internal_error(r::_RESTResponse; var::AbstractString)
372-
if !(r.status == 200)
373-
return nothing
374-
end
375-
success = _get_json_or(r.json, "success", Any, nothing)
376-
internal_error = _get_json_or(r.json, "internal_error", Any, nothing)
377-
if (success === false) && (internal_error === true)
378-
e = JuliaHubError(
379-
"""
380-
Internal Server Error 200 response from JuliaHub ($var):
381-
JSON: $(sprint(show, MIME("text/plain"), r.json))
382-
""",
383-
)
384-
throw(e)
385-
end
386-
return nothing
387-
end
388-
389364
# Performs the print of f(::IO), but prepends `indent` spaces in front of
390365
# each line, to make it indented.
391366
function _print_indented(io::IO, f; indent::Integer)

0 commit comments

Comments
 (0)