From 7e744b2e66d8309ef003b345cf34caa6240ff8b7 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Thu, 28 Sep 2023 22:34:13 +0100 Subject: ui: Split out reporting of &formatted-message conditions. * ccwl/ui.scm (report-formatted-message): New public function. (report-ccwl-violation): Use report-formatted-message. --- ccwl/ui.scm | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/ccwl/ui.scm b/ccwl/ui.scm index 97e5d09..7be50be 100644 --- a/ccwl/ui.scm +++ b/ccwl/ui.scm @@ -1,5 +1,5 @@ ;;; ccwl --- Concise Common Workflow Language -;;; Copyright © 2022 Arun Isaac +;;; Copyright © 2022, 2023 Arun Isaac ;;; ;;; This file is part of ccwl. ;;; @@ -21,7 +21,18 @@ #:use-module (srfi srfi-26) #:use-module (srfi srfi-28) #:use-module (ccwl conditions) - #:export (report-ccwl-violation)) + #:export (report-formatted-message + report-ccwl-violation)) + +(define (report-formatted-message exception) + "Report @var{exception}, a @code{&formatted-message} condition to the +user." + (display (apply format + (formatted-message-format exception) + (map (compose bold magenta) + (formatted-message-arguments exception))) + (current-error-port)) + (newline (current-error-port))) (define (repeat thunk n) "Call THUNK N times." @@ -161,12 +172,8 @@ red. LINE-NUMBER and COLUMN-NUMBER are zero-based." (display (bold (red "error:")) (current-error-port)) (display " " (current-error-port)) - (display (apply format - (formatted-message-format exception) - (map (compose bold magenta) - (formatted-message-arguments exception))) - (current-error-port)) - (newline (current-error-port)) + (when (formatted-message? exception) + (report-formatted-message exception)) (display-with-line-numbers (source-in-context file line column) (current-error-port) (max 1 line)))) -- cgit v1.2.3