         promise.done (response) =>
           for name, file of response.files
             notebook.handle_file @, file, options
-        promise.fail (response, status_text, error) =>
-          @fns.error status_text
+        promise.fail (response) =>
+          @fns.error response.statusText
 
   cmd 'save_gist', 'Saves a notebook as a gist', ->
     notebook = @export_notebook()

        else
          gist


  cmd 'gist', 'Loads a script from a gist', (gist, options={}) ->
    if arguments.length is 0

      settings.get 'githubs', host

    default: -> settings.get 'default'

    get_repo_contents: (url) ->
      http.get(url)
      .then (response) ->
        file =
          content: atob response.content.replace /\n/g, ''
          filename: response.name
          type: 'application/octet-stream'

    to_repo_url: (path) ->
      path = path.toString()
      if path.indexOf('http') != 0
        site = settings.get 'githubs', github.default()
        path = path.substr 1 if path[0] == '/'
        [user, repo, segments...] = path.split '/'
        url = "#{site.api_base_url}/repos/#{user}/#{repo}/contents/#{segments.join '/'}"
      else
        site = github.get_github path
        if path.indexOf(site.api_base_url) == 0
          url = path
        else
          uri = URI path
          path = uri.pathname()
          path = path.substr 1 if path[0] == '/'
          [user, repo, x, ref, segments...] = path.split '/'
          url = "#{site.api_base_url}/repos/#{user}/#{repo}/contents/#{segments.join '/'}?ref=#{ref}"

    save_gist: (gist, options={}) ->
      github_host = options.github ? github.default()
