Use valid JSON for error responses
This commit is contained in:
parent
7f63a5a81c
commit
7e8e212321
|
@ -32,6 +32,8 @@ module Travis::Api
|
||||||
|
|
||||||
Rack.autoload :SSL, 'rack/ssl'
|
Rack.autoload :SSL, 'rack/ssl'
|
||||||
|
|
||||||
|
ERROR_RESPONSE = JSON.generate(error: 'Travis encountered an error, sorry :(')
|
||||||
|
|
||||||
# Used to track if setup already ran.
|
# Used to track if setup already ran.
|
||||||
def self.setup?
|
def self.setup?
|
||||||
@setup ||= false
|
@setup ||= false
|
||||||
|
@ -113,7 +115,7 @@ module Travis::Api
|
||||||
app.call(env)
|
app.call(env)
|
||||||
rescue
|
rescue
|
||||||
if Endpoint.production?
|
if Endpoint.production?
|
||||||
[500, {'Content-Type' => 'application/json'}, ["{'error': 'Travis encountered an error, sorry :('}"]]
|
[500, {'Content-Type' => 'application/json'}, [ERROR_RESPONSE]]
|
||||||
else
|
else
|
||||||
raise
|
raise
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user