Merge pull request #74 from halorgium/fix-error-response

Use valid JSON for error responses
This commit is contained in:
Piotr Sarnacki 2013-09-23 09:53:55 -07:00
commit d7d2fd5149

View File

@ -35,6 +35,8 @@ module Travis::Api
Rack.autoload :SSL, 'rack/ssl'
ERROR_RESPONSE = JSON.generate(error: 'Travis encountered an error, sorry :(')
# Used to track if setup already ran.
def self.setup?
@setup ||= false
@ -117,7 +119,7 @@ module Travis::Api
app.call(env)
rescue
if Endpoint.production?
[500, {'Content-Type' => 'application/json'}, ["{'error': 'Travis encountered an error, sorry :('}"]]
[500, {'Content-Type' => 'application/json'}, [ERROR_RESPONSE]]
else
raise
end