Skip to content

Commit 54ebe51

Browse files
committed
Render JSON error when it occurs on a request path ending with .json
While ACCEPT header might not be passed in these requests, paths ending with .json are likely to expect a JSON response, so when an error occurs, respond with a JSON error. This fixes error modal in such requests and displays an informative message now instead of empty content.
1 parent 57098c3 commit 54ebe51

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

lib/sequenceserver/routes.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ class Routes < Sinatra::Base
297297
error_data[:more_info] = error.backtrace.join("\n")
298298
end
299299

300-
if request.env['HTTP_ACCEPT'].to_s.include?('application/json')
300+
if request.env['HTTP_ACCEPT'].to_s.include?('application/json') || request.path.end_with?('.json')
301301
status 422
302302
content_type :json
303303
error_data.to_json

0 commit comments

Comments
 (0)