1
0
mirror of https://codeberg.org/cage/tinmop/ synced 2024-12-23 23:51:50 +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)
(find-db-stream-if (lambda (a) (string= (server-stream-handle a) url))))
(defun notify-request-error (e)
(let ((message (format nil (_ "Comunication with backend failed: ~a") e)))
#+debug-mode (misc:dbg "request error ~a" message)
#-debug-mode (gui-goodies:error-dialog gui-goodies:*toplevel* message)))
(defun notify-request-error (message)
(gui-goodies:error-dialog gui-goodies:*toplevel* message))
(defmacro with-notify-errors (&body body)
`(handler-case
(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)
#+debug-mode (misc:dbg "backend comunication error ~a" 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
(use-cache t)
(process-function #'identity)
(aborting-function (constantly nil)))
(cev:with-enqueue-request (:gemini-request 1 the-error iri use-cache)
(notify-request-error the-error))
(enqueue-request-notify-error :gemini-request 1 iri use-cache)
(labels ((stream-exausted-p ()
(let ((status-completed (cev:with-enqueue-request
(:gemini-stream-completed-p 1 the-error iri)
(notify-request-error the-error))))
(let ((status-completed (enqueue-request-notify-error :gemini-stream-completed-p
1
iri)))
status-completed))
(loop-fetch (&optional (last-lines-fetched-count 0))
(when (not (or (funcall aborting-function)

View File

@ -27,13 +27,11 @@
(loop while (events-loop-running-p) do
(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 ()
(handler-case
(comm:make-request ,method-name ,id ,@args)
(error (,the-error)
(declare (ignorable ,the-error))
,@on-error))))
,@on-error)))
(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))

View File

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

View File

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