aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2023-09-28 22:34:13 +0100
committerArun Isaac2023-09-28 22:36:07 +0100
commit7e744b2e66d8309ef003b345cf34caa6240ff8b7 (patch)
tree2a13117afa977c83ba274b0537b5df89fd496913
parent1ec0bef2bdc8c1b937eef71f93d35e98f0f2f688 (diff)
downloadccwl-7e744b2e66d8309ef003b345cf34caa6240ff8b7.tar.gz
ccwl-7e744b2e66d8309ef003b345cf34caa6240ff8b7.tar.lz
ccwl-7e744b2e66d8309ef003b345cf34caa6240ff8b7.zip
ui: Split out reporting of &formatted-message conditions.
* ccwl/ui.scm (report-formatted-message): New public function. (report-ccwl-violation): Use report-formatted-message.
-rw-r--r--ccwl/ui.scm23
1 files 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 <arunisaac@systemreboot.net>
+;;; Copyright © 2022, 2023 Arun Isaac <arunisaac@systemreboot.net>
;;;
;;; 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))))