1
0
mirror of https://codeberg.org/cage/tinmop/ synced 2024-12-25 00:00:54 +01:00

- [GUI] removed useless information (for users) when showing errors (RPC errors contained the whole request as sexp).

- [GUI] removed warning about missing variable 'gui-goodies:*gui-server*' in file containing the gui event loop.
This commit is contained in:
cage 2023-02-19 16:15:10 +01:00
parent cefbe59be6
commit a4f6e87765
4 changed files with 28 additions and 15 deletions

View File

@ -62,27 +62,37 @@
(defun find-db-stream-url (url) (defun find-db-stream-url (url)
(find-db-stream-if (lambda (a) (string= (server-stream-handle a) url)))) (find-db-stream-if (lambda (a) (string= (server-stream-handle a) url))))
(defun notify-request-error (e) (defun notify-request-error (message)
(let ((message (format nil (_ "Comunication with backend failed: ~a") e))) (gui-goodies:error-dialog gui-goodies:*toplevel* message))
#+debug-mode (misc:dbg "request error ~a" message)
#-debug-mode (gui-goodies:error-dialog gui-goodies:*toplevel* message)))
(defmacro with-notify-errors (&body body) (defmacro with-notify-errors (&body body)
`(handler-case `(handler-case
(progn ,@body) (progn ,@body)
(comm:rpc-error-response (e)
#+debug-mode (misc:dbg "backend comunication RPC error ~a" e)
(notify-request-error (format nil
(_ "~a: ~a")
(comm:code e)
(conditions:text e))))
(error (e) (error (e)
#+debug-mode (misc:dbg "backend comunication error ~a" e)
(notify-request-error e)))) (notify-request-error e))))
(defun enqueue-request-notify-error (method-name id &rest args)
(ev:with-enqueued-process-and-unblock ()
(with-notify-errors
(apply #'comm:make-request method-name id args))))
(defun slurp-gemini-stream (iri &key (defun slurp-gemini-stream (iri &key
(use-cache t) (use-cache t)
(process-function #'identity) (process-function #'identity)
(aborting-function (constantly nil))) (aborting-function (constantly nil)))
(cev:with-enqueue-request (:gemini-request 1 the-error iri use-cache) (enqueue-request-notify-error :gemini-request 1 iri use-cache)
(notify-request-error the-error))
(labels ((stream-exausted-p () (labels ((stream-exausted-p ()
(let ((status-completed (cev:with-enqueue-request (let ((status-completed (enqueue-request-notify-error :gemini-stream-completed-p
(:gemini-stream-completed-p 1 the-error iri) 1
(notify-request-error the-error)))) iri)))
status-completed)) status-completed))
(loop-fetch (&optional (last-lines-fetched-count 0)) (loop-fetch (&optional (last-lines-fetched-count 0))
(when (not (or (funcall aborting-function) (when (not (or (funcall aborting-function)

View File

@ -27,13 +27,11 @@
(loop while (events-loop-running-p) do (loop while (events-loop-running-p) do
(ev:dispatch-program-events-or-wait))))))) (ev:dispatch-program-events-or-wait)))))))
(defmacro with-enqueue-request ((method-name id the-error &rest args) &body on-error) (defmacro with-enqueue-request ((method-name id &rest args) &body on-error)
`(ev:with-enqueued-process-and-unblock () `(ev:with-enqueued-process-and-unblock ()
(handler-case (handler-case
(comm:make-request ,method-name ,id ,@args) (comm:make-request ,method-name ,id ,@args)
(error (,the-error) ,@on-error)))
(declare (ignorable ,the-error))
,@on-error))))
(defun enqueue-request-and-wait-results (method-name id priority &rest args) (defun enqueue-request-and-wait-results (method-name id priority &rest args)
(ev:push-function-and-wait-results (lambda () (apply #'comm:make-request method-name id args)) (ev:push-function-and-wait-results (lambda () (apply #'comm:make-request method-name id args))

View File

@ -3212,7 +3212,12 @@
:start-server :start-server
:close-server :close-server
:make-request :make-request
:start-client)) :start-client
:rpc-error-response
:message
:data
:code
:id))
(defpackage :client-configuration (defpackage :client-configuration
(:use (:use

View File

@ -159,10 +159,10 @@
:pathname "gui/client" :pathname "gui/client"
:components ((:file "constants") :components ((:file "constants")
(:file "client-configuration") (:file "client-configuration")
(:file "gui-goodies")
(:file "program-events") (:file "program-events")
(:file "json-rpc-communication") (:file "json-rpc-communication")
(:file "validation") (:file "validation")
(:file "gui-goodies")
(:file "icons") (:file "icons")
(:file "menu-command") (:file "menu-command")
(:file "main-window"))) (:file "main-window")))