           (lambda (location)
             (when location
               (if (assoc-default 'exception location)
-                  (ycmd--handle-goto-exception location)
+                  (ycmd--handle-exception location #'ycmd--handle-goto-exception)
                 (ycmd--handle-goto-success location)))))))))
 
 (defun ycmd--goto-location (location)

       content
       :parser 'json-read))))

(defun ycmd-goto ()
  "Go to the definition or declaration (whichever is most
sensible) of the symbol at the current position."

  (interactive)
  (ycmd--conditional-parse))

(defun ycmd--handle-notify-exception (result)
  "Handle a notify exception.

If EX is an exception of type `UnknownExtraConf', handle
configuration file according the value of
`ycmd-extra-conf-handler'."
  (deferred:$
    (let ((conf-file (assoc-default 'extra_conf_file
                                    (assoc-default 'exception result))))
      (cond ((not conf-file)
             (warn "No extra_conf_file included in UnknownExtraConf exception. Consider reporting this."))

            ((or (eq ycmd-extra-conf-handler 'load)
                 (and (eq ycmd-extra-conf-handler 'ask)
                      (y-or-n-p (format "Load YCMD extra conf %s?" conf-file))))
             (ycmd--request "/load_extra_conf_file"
                            `((filepath . ,conf-file))))

            (t
             (ycmd--request "/ignore_extra_conf_file"
                            `((filepath . ,conf-file))))))
    (ycmd-notify-file-ready-to-parse)))

(defun ycmd--handle-notify-response (results)
  "If RESULTS is a vector, the response is an acual parse result.
Otherwise the response is probably an exception."
  (if (vectorp results)
      (run-hook-with-args 'ycmd-file-parse-result-hook results)
    (when (assoc 'exception results)
      (ycmd--handle-exception results))))

(defun ycmd-notify-file-ready-to-parse ()
  "Send a notification to ycmd that the buffer is ready to be parsed.
