Show GitHub API error message when markdown preview fails

This commit is contained in:
Corey Johnson
2013-03-25 14:59:29 -07:00
committed by probablycorey
parent 55d4625091
commit 2944b64795

View File

@@ -32,15 +32,20 @@ class MarkdownPreviewView extends ScrollView
getPath: ->
@buffer.getPath()
setErrorHtml: ->
setErrorHtml: (result)->
try failureMessage = JSON.parse(result.responseText).message
@html $$$ ->
@h2 'Previewing Markdown Failed'
@h3 'Possible Reasons'
@ul =>
@li =>
@span 'You aren\'t online or are unable to reach '
@a 'github.com', href: 'https://github.com'
@span '.'
if failureMessage?
@h3 failureMessage
else
@h3 'Possible Reasons'
@ul =>
@li =>
@span 'You aren\'t online or are unable to reach '
@a 'github.com', href: 'https://github.com'
@span '.'
setLoading: ->
@html($$$ -> @div class: 'markdown-spinner', 'Loading Markdown...')
@@ -56,4 +61,4 @@ class MarkdownPreviewView extends ScrollView
mode: 'markdown'
text: @buffer.getText()
success: (html) => @html(html)
error: => @setErrorHtml()
error: (result) => @setErrorHtml(result)