From a4f6e877659c6b119e268470c0e18b75a484f018 Mon Sep 17 00:00:00 2001 From: cage Date: Sun, 19 Feb 2023 16:15:10 +0100 Subject: [PATCH] - [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. --- src/gui/client/main-window.lisp | 28 +++++++++++++++++++--------- src/gui/client/program-events.lisp | 6 ++---- src/package.lisp | 7 ++++++- tinmop.asd | 2 +- 4 files changed, 28 insertions(+), 15 deletions(-) diff --git a/src/gui/client/main-window.lisp b/src/gui/client/main-window.lisp index 926a1d5..51be7b7 100644 --- a/src/gui/client/main-window.lisp +++ b/src/gui/client/main-window.lisp @@ -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) diff --git a/src/gui/client/program-events.lisp b/src/gui/client/program-events.lisp index 6d34802..d7d23f8 100644 --- a/src/gui/client/program-events.lisp +++ b/src/gui/client/program-events.lisp @@ -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)) diff --git a/src/package.lisp b/src/package.lisp index acd71db..af61e24 100644 --- a/src/package.lisp +++ b/src/package.lisp @@ -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 diff --git a/tinmop.asd b/tinmop.asd index fdd9361..4314270 100644 --- a/tinmop.asd +++ b/tinmop.asd @@ -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")))