From b37c590265e277d729eb8e45bad85628367db152 Mon Sep 17 00:00:00 2001 From: cage Date: Tue, 2 Feb 2021 20:44:18 +0100 Subject: [PATCH] - prevented crash when sending message to command did not worked. Printing error to command line instead. --- src/package.lisp | 1 + src/program-events.lisp | 3 ++- src/tui-utils.lisp | 8 ++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/package.lisp b/src/package.lisp index 7d4757f..806f1b5 100644 --- a/src/package.lisp +++ b/src/package.lisp @@ -1186,6 +1186,7 @@ :colorized-line->tui-string :standard-error-notify-life :with-notify-errors + :with-print-error-message :make-tui-char :make-tui-string)) diff --git a/src/program-events.lisp b/src/program-events.lisp index 9432448..c487ea7 100644 --- a/src/program-events.lisp +++ b/src/program-events.lisp @@ -1384,7 +1384,8 @@ (defmethod process-event ((object send-to-pipe-event)) (with-accessors ((data data) (command command)) object - (os-utils:send-to-pipe data command))) + (tui:with-print-error-message + (os-utils:send-to-pipe data command)))) ;;;; general usage diff --git a/src/tui-utils.lisp b/src/tui-utils.lisp index 46e5597..e8bd228 100644 --- a/src/tui-utils.lisp +++ b/src/tui-utils.lisp @@ -398,3 +398,11 @@ latter has a length equals to `total-size'")) (ui:notify (format nil (_ "Error: ~a") e) :life (* (swconf:config-notification-life) 5) :as-error t)))) + +(defmacro with-print-error-message (&body body) + #+debug-mode `(progn ,@body) + #-debug-mode `(handler-case + (progn + ,@body) + (error (e) + (ui:error-message (format nil (_ "Error: ~a") e)))))