Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
shuxiao9058 committed Jul 18, 2023
1 parent ff1b6aa commit 2623c78
Showing 1 changed file with 29 additions and 29 deletions.
58 changes: 29 additions & 29 deletions tabnine-chat-curl.el
Original file line number Diff line number Diff line change
Expand Up @@ -155,26 +155,26 @@ PROCESS and _STATUS are process parameters."
(insert "\n\n" (tabnine-chat-prompt-prefix-string)))))
(with-current-buffer tabnine-chat-buffer
(when tabnine-chat-mode (tabnine-chat--update-header-line " Ready" 'success))))
;; Or Capture error message
(with-current-buffer proc-buf
(goto-char (point-max))
(search-backward (plist-get info :token))
(backward-char)
(pcase-let* ((`(,_ . ,header-size) (read (current-buffer)))
(json-object-type 'plist)
(response (progn (goto-char header-size)
(condition-case nil (json-read)
(json-readtable-error 'json-read-error)))))
(cond
((plist-get response :error)
(let* ((error-plist (plist-get response :error))
(error-msg (plist-get error-plist :message))
(error-type (plist-get error-plist :type)))
(message "TabNine Chat error: (%s) %s" http-msg error-msg)
(setq http-msg (concat "(" http-msg ") " (string-trim error-type)))))
((eq response 'json-read-error)
(message "TabNine Chat error (%s): Malformed JSON in response." http-msg))
(t (message "TabNine Chat error (%s): Could not parse HTTP response." http-msg)))))
;; ;; Or Capture error message
;; (with-current-buffer proc-buf
;; (goto-char (point-max))
;; (search-backward (plist-get info :token))
;; (backward-char)
;; (pcase-let* ((`(,_ . ,header-size) (read (current-buffer)))
;; (json-object-type 'plist)
;; (response (progn (goto-char header-size)
;; (condition-case nil (json-read)
;; (json-readtable-error 'json-read-error)))))
;; (cond
;; ((plist-get response :error)
;; (let* ((error-plist (plist-get response :error))
;; (error-msg (plist-get error-plist :message))
;; (error-type (plist-get error-plist :type)))
;; (message "TabNine Chat error: (%s) %s" http-msg error-msg)
;; (setq http-msg (concat "(" http-msg ") " (string-trim error-type)))))
;; ((eq response 'json-read-error)
;; (message "TabNine Chat error (%s): Malformed JSON in response." http-msg))
;; (t (message "TabNine Chat error (%s): Could not parse HTTP response." http-msg)))))
(with-current-buffer tabnine-chat-buffer
(when tabnine-chat-mode
(tabnine-chat--update-header-line
Expand Down Expand Up @@ -305,7 +305,7 @@ buffer."
(goto-char (point-max))
(search-backward token)
(backward-char)
(pcase-let* ((`(,_ . ,header-size) (read (current-buffer))))
(pcase-let* ((`(,_ . ,_) (read (current-buffer))))
;; (if (search-backward token nil t)
;; (search-forward ")" nil t)
;; (goto-char (point-min)))
Expand All @@ -331,14 +331,14 @@ buffer."
(ss (cl-remove-if (lambda(x) (not (s-present? x))) ss))
(json-ss (mapcar (lambda(x) (tabnine-util--read-json x)) ss)))
(list (tabnine-chat--results-to-text json-ss) http-msg)))
((plist-get response :error)
(let* ((error-plist (plist-get response :error))
(error-msg (plist-get error-plist :message))
(error-type (plist-get error-plist :type)))
(list nil (concat "(" http-msg ") " (string-trim error-type)) error-msg)))
((eq response 'json-read-error)
(list nil (concat "(" http-msg ") Malformed JSON in response.")
"Malformed JSON in response"))
;; ((plist-get response :error)
;; (let* ((error-plist (plist-get response :error))
;; (error-msg (plist-get error-plist :message))
;; (error-type (plist-get error-plist :type)))
;; (list nil (concat "(" http-msg ") " (string-trim error-type)) error-msg)))
;; ((eq response 'json-read-error)
;; (list nil (concat "(" http-msg ") Malformed JSON in response.")
;; "Malformed JSON in response"))
(t (list nil (concat "(" http-msg ") Could not parse HTTP response.")
"Could not parse HTTP response.")))
(list nil (concat "(" http-msg ") Could not parse HTTP response.")
Expand Down

0 comments on commit 2623c78

Please sign in to comment.