Skip to content

Commit

Permalink
When html is recieved instead of JSON the error message says this rat…
Browse files Browse the repository at this point in the history
…her than dumping the html on the screen as the error message
  • Loading branch information
Calvin Pomerantz committed Mar 14, 2016
1 parent ac08c15 commit fbe408a
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions SingularityUI/app/application.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,12 @@ class Application
serverMessage = JSON.parse(jqxhr.responseText).message or jqxhr.responseText
catch
if jqxhr.status is 200
console.error jqxhr
console.error jqxhr.responseText
Messenger().error
message: '''
<p>Expected JSON but received something else (possibly html). The response has been saved to your js console.</p>
<p>One possible cause is an http redirect to an html web page.</p>
'''
throw new Error "Expected JSON in response but received something else"
message: """
<p>Expected JSON but received #{if jqxhr.responseText.startsWith '<!DOCTYPE html>' then 'html' else 'something else'}. The response has been saved to your js console.</p>
"""
throw new Error "Expected JSON in response but received #{if jqxhr.responseText.startsWith '<!DOCTYPE html>' then 'html' else 'something else'}"
serverMessage = jqxhr.responseText

serverMessage = _.escape serverMessage
Expand Down

0 comments on commit fbe408a

Please # to comment.