* bug#41956: [PATCH] ice-9: exceptions: Properly format the error message.
@ 2020-06-19 21:33 Maxim Cournoyer
2020-06-20 5:46 ` maxim.cournoyer
2021-06-02 7:32 ` bug#41956: is this still current ? Adriano Peluso
0 siblings, 2 replies; 12+ messages in thread
From: Maxim Cournoyer @ 2020-06-19 21:33 UTC (permalink / raw)
To: 41956
[-- Attachment #1: Type: text/plain, Size: 1286 bytes --]
Hello,
I had this problem in Guix where 'guix deploy my-config.scm' would
unhelpfully report an error like:
guix deploy: error: failed to deploy my-host: ~A: ~S
Digging a bit, I could reproduce at the REPL with:
--8<---------------cut here---------------start------------->8---
(guard (c ((message-condition? c)
(format #t "error: ~a~%" (condition-message c))))
;; This is what (canonicalize-path "/do/not/exist) ends up doing:
(throw 'system-error "canonicalize-path" "~A" '("No such file or directory")))
--> error: ~A
--8<---------------cut here---------------end--------------->8---
It seems our native -> srfi-34 style exception converter should populate
the message field with a formatted message, given that's what happens to
present errors as explained in libguile/error.c:
When an error is reported,\n
"these are replaced by formatting the corresponding members of\n"
"@var{args}: @code{~A} (was @code{%s} in older versions of\n"
"Guile) formats using @code{display} and @code{~S}
I'm not sure about the second ~S that appeared in the Guix output;
possibly the exception got re-thrown and suffered from a slightly
different conversion problem?
Anyway, the simple patch attached should fix the "~A" exception message.
Thank you,
Maxim
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ice-9-exceptions-Properly-format-the-error-message.patch --]
[-- Type: text/x-patch, Size: 1248 bytes --]
From adaa2f66fec7684e9e65491158afc5923613e3da Mon Sep 17 00:00:00 2001
From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Date: Fri, 19 Jun 2020 14:30:05 -0400
Subject: [PATCH] ice-9: exceptions: Properly format the error message.
Before this change, native exceptions such as system errors caught with
srfi-34's `guard' would be converted to an exception with its message
unhelpfully set to "~A".
Thus, apply the message arguments to the message format to derive a human
readable exception message.
* module/ice-9/exceptions.scm (guile-common-exceptions): Format the
message string using its arguments.
---
module/ice-9/exceptions.scm | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/module/ice-9/exceptions.scm b/module/ice-9/exceptions.scm
index 143e7aa3e..c990790e9 100644
--- a/module/ice-9/exceptions.scm
+++ b/module/ice-9/exceptions.scm
@@ -189,7 +189,7 @@
((subr msg margs . _)
(make-exception
(make-exception-with-origin subr)
- (make-exception-with-message msg)
+ (make-exception-with-message (apply format #f msg margs))
(make-exception-with-irritants margs)))
(_ (make-exception-with-irritants args)))
args))
--
2.26.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* bug#41956: [PATCH] ice-9: exceptions: Properly format the error message.
2020-06-19 21:33 bug#41956: [PATCH] ice-9: exceptions: Properly format the error message Maxim Cournoyer
@ 2020-06-20 5:46 ` maxim.cournoyer
2020-06-20 18:33 ` Bengt Richter
2021-06-02 7:32 ` bug#41956: is this still current ? Adriano Peluso
1 sibling, 1 reply; 12+ messages in thread
From: maxim.cournoyer @ 2020-06-20 5:46 UTC (permalink / raw)
To: Maxim Cournoyer; +Cc: 41956
Maxim Cournoyer <maxim.cournoyer@gmail.com> writes:
> Hello,
>
> I had this problem in Guix where 'guix deploy my-config.scm' would
> unhelpfully report an error like:
>
> guix deploy: error: failed to deploy my-host: ~A: ~S
>
> Digging a bit, I could reproduce at the REPL with:
>
> (guard (c ((message-condition? c)
> (format #t "error: ~a~%" (condition-message c))))
> ;; This is what (canonicalize-path "/do/not/exist) ends up doing:
> (throw 'system-error "canonicalize-path" "~A" '("No such file or directory")))
>
> --> error: ~A
[...]
Unfortunately the previous patch breaks the tests, with errors like:
ERROR: bytevectors.test: Datum Syntax: incorrect prefix - arguments: ((wrong-type-arg "apply" "Apply to non-list: ~S" (#\i) (#\i)))
I'm out of ideas for now, I last tried:
--8<---------------cut here---------------start------------->8---
modified module/ice-9/exceptions.scm
@@ -189,7 +189,10 @@
((subr msg margs . _)
(make-exception
(make-exception-with-origin subr)
- (make-exception-with-message msg)
+ (let ((msg (if (null? margs)
+ msg
+ (apply simple-format #f msg margs))))
+ (make-exception-with-message msg))
(make-exception-with-irritants margs)))
(_ (make-exception-with-irritants args)))
args))
--8<---------------cut here---------------end--------------->8---
To the same effect.
Maxim
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#41956: [PATCH] ice-9: exceptions: Properly format the error message.
2020-06-20 5:46 ` maxim.cournoyer
@ 2020-06-20 18:33 ` Bengt Richter
2020-06-21 3:49 ` Maxim Cournoyer
0 siblings, 1 reply; 12+ messages in thread
From: Bengt Richter @ 2020-06-20 18:33 UTC (permalink / raw)
To: maxim.cournoyer; +Cc: 41956
Hi Maxim,
tl;dr:
Does module/ice-9/exceptions.scm use the default format?
Maybe (use-modules (ice-9) format) will help get to the next bug ?? :)
On +2020-06-20 01:46:13 -0400, maxim.cournoyer@gmail.com wrote:
> Maxim Cournoyer <maxim.cournoyer@gmail.com> writes:
>
> > Hello,
> >
> > I had this problem in Guix where 'guix deploy my-config.scm' would
> > unhelpfully report an error like:
> >
> > guix deploy: error: failed to deploy my-host: ~A: ~S
> >
> > Digging a bit, I could reproduce at the REPL with:
> >
> > (guard (c ((message-condition? c)
> > (format #t "error: ~a~%" (condition-message c))))
> > ;; This is what (canonicalize-path "/do/not/exist) ends up doing:
> > (throw 'system-error "canonicalize-path" "~A" '("No such file or directory")))
> >
> > --> error: ~A
>
> [...]
>
> Unfortunately the previous patch breaks the tests, with errors like:
>
> ERROR: bytevectors.test: Datum Syntax: incorrect prefix - arguments: ((wrong-type-arg "apply" "Apply to non-list: ~S" (#\i) (#\i)))
>
> I'm out of ideas for now, I last tried:
>
> --8<---------------cut here---------------start------------->8---
> modified module/ice-9/exceptions.scm
> @@ -189,7 +189,10 @@
> ((subr msg margs . _)
> (make-exception
> (make-exception-with-origin subr)
> - (make-exception-with-message msg)
> + (let ((msg (if (null? margs)
> + msg
> + (apply simple-format #f msg margs))))
> + (make-exception-with-message msg))
> (make-exception-with-irritants margs)))
> (_ (make-exception-with-irritants args)))
> args))
> --8<---------------cut here---------------end--------------->8---
>
> To the same effect.
>
> Maxim
>
>
>
HTH
--
Regards,
Bengt Richter
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#41956: [PATCH] ice-9: exceptions: Properly format the error message.
2020-06-20 18:33 ` Bengt Richter
@ 2020-06-21 3:49 ` Maxim Cournoyer
2020-06-25 10:04 ` Ricardo Wurmus
0 siblings, 1 reply; 12+ messages in thread
From: Maxim Cournoyer @ 2020-06-21 3:49 UTC (permalink / raw)
To: Bengt Richter; +Cc: 41956
Hello Bengt!
Bengt Richter <bokr@bokr.com> writes:
> Hi Maxim,
>
> tl;dr:
> Does module/ice-9/exceptions.scm use the default format?
> Maybe (use-modules (ice-9) format) will help get to the next bug ?? :)
Thanks for suggesting! I tried but got the same result.
I'm now testing a slightly different version:
@@ -189,7 +189,10 @@
((subr msg margs . _)
(make-exception
(make-exception-with-origin subr)
- (make-exception-with-message msg)
+ (let ((msg (if (list? margs)
+ (apply simple-format #f msg margs)
+ msg)))
+ (make-exception-with-message msg))
(make-exception-with-irritants margs)))
(_ (make-exception-with-irritants args)))
args))
Maxim
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#41956: [PATCH] ice-9: exceptions: Properly format the error message.
2020-06-21 3:49 ` Maxim Cournoyer
@ 2020-06-25 10:04 ` Ricardo Wurmus
2020-06-25 16:33 ` Bengt Richter
2020-06-28 4:17 ` Maxim Cournoyer
0 siblings, 2 replies; 12+ messages in thread
From: Ricardo Wurmus @ 2020-06-25 10:04 UTC (permalink / raw)
To: Maxim Cournoyer; +Cc: 41956
Hi Maxim,
here’s what I did in the REPL:
--8<---------------cut here---------------start------------->8---
scheme@(guile-user)> ,m (ice-9 exceptions)
scheme@(ice-9 exceptions)> (define (my/guile-system-error-converter key args)
(apply (case-lambda
((subr msg-args msg errno . rest)
;; XXX TODO we should return a more specific error
;; (usually an I/O error) as expected by R6RS programs.
;; Unfortunately this often requires the 'filename' (or
;; other?) which is not currently provided by the native
;; Guile exceptions.
(make-exception
(make-external-error)
(make-exception-with-origin subr)
(apply make-exception-with-message msg)
(make-exception-with-irritants msg-args)))
(_ (guile-external-error-converter key args)))
args))
scheme@(ice-9 exceptions)> (set! guile-exception-converters (acons 'system-error my/guile-system-error-converter guile-exception-converters))
scheme@(ice-9 exceptions)> ,m (guile-user)
scheme@(guile-user)> (guard (c ((message-condition? c)
(format #t "message: ~a~%" (condition-message c))))
(canonicalize-path "/doesntexist"))
message: No such file or directory
$11 = #t
scheme@(guile-user)>
--8<---------------cut here---------------end--------------->8---
--
Ricardo
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#41956: [PATCH] ice-9: exceptions: Properly format the error message.
2020-06-25 10:04 ` Ricardo Wurmus
@ 2020-06-25 16:33 ` Bengt Richter
2020-06-28 4:25 ` Maxim Cournoyer
2020-06-28 4:17 ` Maxim Cournoyer
1 sibling, 1 reply; 12+ messages in thread
From: Bengt Richter @ 2020-06-25 16:33 UTC (permalink / raw)
To: Ricardo Wurmus; +Cc: 41956
Hi Ricardo et al,
On +2020-06-25 12:04:27 +0200, Ricardo Wurmus wrote:
>
> Hi Maxim,
>
> here’s what I did in the REPL:
>
> --8<---------------cut here---------------start------------->8---
> scheme@(guile-user)> ,m (ice-9 exceptions)
> scheme@(ice-9 exceptions)> (define (my/guile-system-error-converter key args)
> (apply (case-lambda
> ((subr msg-args msg errno . rest)
> ;; XXX TODO we should return a more specific error
> ;; (usually an I/O error) as expected by R6RS programs.
> ;; Unfortunately this often requires the 'filename' (or
> ;; other?) which is not currently provided by the native
> ;; Guile exceptions.
> (make-exception
> (make-external-error)
> (make-exception-with-origin subr)
> (apply make-exception-with-message msg)
> (make-exception-with-irritants msg-args)))
> (_ (guile-external-error-converter key args)))
> args))
> scheme@(ice-9 exceptions)> (set! guile-exception-converters (acons 'system-error my/guile-system-error-converter guile-exception-converters))
> scheme@(ice-9 exceptions)> ,m (guile-user)
> scheme@(guile-user)> (guard (c ((message-condition? c)
> (format #t "message: ~a~%" (condition-message c))))
> (canonicalize-path "/doesntexist"))
> message: No such file or directory
> $11 = #t
> scheme@(guile-user)>
> --8<---------------cut here---------------end--------------->8---
>
> --
> Ricardo
What do you think of using (ice-9 match) to make a universal throwage-formatter,
with the idea of making readable top level code for how exceptions become messages on screen?
I started a hack to explore the (throw 'whatever any ...) space, beginning like
--8<---------------cut here---------------start------------->8---
(use-modules (ice-9 match))
(define (make-exception-message key rest)
(begin
(let*((l (cons key rest)))
(match l
(('system-error subr message args data ...)
;; e.g. thrown with key 'system-error: ("open-fdes" "~A" ("No such file or directory") (2))
(format #f (string-append "match-1: subr ~s threw '~s " message " sterror: ~s") subr key args (strerror (car (car data)))))
(('signal any ...)
;; not yet implemented
(format #f "match-2: <NYI:unix signal no> any: ~s" any))
(('keyword-argument-error subr message args data)
;; with-crossed-fingers...
(format #f (string-append "match-3: subr ~s threw '~s " message) subr key args))
;; FIXME: string-append formats NAGI not a good idea, see a fix example below
(('wrong-type-arg subr message (args ...) (data ...))
;; E.g., thrown with key 'wrong-type-arg: ("sqrt" "Wrong type argument in position ~A: ~S" (1 x) (x))
(format #f "match-4: subr ~s threw '~s: ~s" subr key (format #f message args data)))
(('out-of-range subr message (lo hi bad1) ((bad2)))
;; E.g., thrown with key 'out-of-range: (#f "Value out of range ~S to ~S: ~S" (0 3 4) (4))
(format #f "match-5: (internal) threw '~s: ~s" 'out-of-range (format #f message lo hi bad2)))
(('unbound-variable #f message args data)
;; E.g. thrown with key 'unbound-variable: (#f "Unbound variable: ~S" (foo) #f)
(format #f (string-append "match-6: subr ~s threw '~s " message) #f key args)) ;; data))
;; FIXME: string-append formats NAGI
[...]
--8<---------------cut here---------------end--------------->8---
I made a guile hack that I could call from bash so I could type a line and (eval-string it) as a source of exceptions,
and found that I could get secondary exceptions from make-exception-message, so I wrapped that with a (catch ...)
something like
--8<---------------cut here---------------start------------->8---
(define verbose-exception-handler (lambda (k . rest )
(begin
(format #t "thrown with key '~s: ~s\n" k rest)
(format #t "catch return=~a\n" (catch #t
(lambda () (make-exception-message k rest))
(lambda (inner-key . inner-rest)
(format #t "caught by inner handler: thrown with key '~s: ~s\n" inner-key inner-rest))))
;; (format #t "thrown with key '~s: ~s\n" k rest)
(newline)
;;;; [...]
--8<---------------cut here---------------end--------------->8---
And using that like
--8<---------------cut here---------------start------------->8---
(define (wrap-main args)
(begin
(display (catch #t
(lambda () (apply main-defaults args))
verbose-exception-handler
))))
--8<---------------cut here---------------end--------------->8---
(main-defaults sets up missing args and calls main with fixed args plus opt rest)
I'm wondering if some of the obscure error messages I've encountered
might be secondary, and could be clarified by wrapping the primary
exception formatting similarly, (adding apropriate hint).
WDYT? And is (ice-9 match) too massive to use for memory-limited platforms?
BTW, does guile have a Content-type X-...-like standard for naming throw keys?,
e.g. 'X-longjump-result-delivery
if someone should want to use throw for non-"standard (?? :)" purposes?
--
Regards, Bengt Richter
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#41956: [PATCH] ice-9: exceptions: Properly format the error message.
2020-06-25 10:04 ` Ricardo Wurmus
2020-06-25 16:33 ` Bengt Richter
@ 2020-06-28 4:17 ` Maxim Cournoyer
2020-06-28 4:31 ` Ricardo Wurmus
1 sibling, 1 reply; 12+ messages in thread
From: Maxim Cournoyer @ 2020-06-28 4:17 UTC (permalink / raw)
To: Ricardo Wurmus; +Cc: 41956
Hello Ricardo!
Ricardo Wurmus <rekado@elephly.net> writes:
> Hi Maxim,
>
> here’s what I did in the REPL:
>
> scheme@(guile-user)> ,m (ice-9 exceptions)
> scheme@(ice-9 exceptions)> (define (my/guile-system-error-converter key args)
> (apply (case-lambda
> ((subr msg-args msg errno . rest)
> ;; XXX TODO we should return a more specific error
> ;; (usually an I/O error) as expected by R6RS programs.
> ;; Unfortunately this often requires the 'filename' (or
> ;; other?) which is not currently provided by the native
> ;; Guile exceptions.
> (make-exception
> (make-external-error)
> (make-exception-with-origin subr)
> (apply make-exception-with-message msg)
> (make-exception-with-irritants msg-args)))
> (_ (guile-external-error-converter key args)))
> args))
> scheme@(ice-9 exceptions)> (set! guile-exception-converters (acons 'system-error my/guile-system-error-converter guile-exception-converters))
> scheme@(ice-9 exceptions)> ,m (guile-user)
> scheme@(guile-user)> (guard (c ((message-condition? c)
> (format #t "message: ~a~%" (condition-message c))))
> (canonicalize-path "/doesntexist"))
> message: No such file or directory
> $11 = #t
> scheme@(guile-user)>
I've tested that this indeed works, although I don't quite understand
how?
This brings embeds the definition of `guile-common-exceptions' into
`guile-system-error-converter', with a single change:
(make-exception-with-message msg) --> (apply make-exception-with-message
msg msg-args)
What is the magic I fail to see?
Is this fix proper to be merged into the original
guile-common-exceptions procedure?
Thank you!
Maxim
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#41956: [PATCH] ice-9: exceptions: Properly format the error message.
2020-06-25 16:33 ` Bengt Richter
@ 2020-06-28 4:25 ` Maxim Cournoyer
2020-06-28 18:23 ` Bengt Richter
0 siblings, 1 reply; 12+ messages in thread
From: Maxim Cournoyer @ 2020-06-28 4:25 UTC (permalink / raw)
To: Bengt Richter; +Cc: 41956
Hello Bengt,
Bengt Richter <bokr@bokr.com> writes:
[...]
> What do you think of using (ice-9 match) to make a universal throwage-formatter,
> with the idea of making readable top level code for how exceptions become messages on screen?
>
> I started a hack to explore the (throw 'whatever any ...) space, beginning like
>
> (use-modules (ice-9 match))
> (define (make-exception-message key rest)
> (begin
> (let*((l (cons key rest)))
> (match l
> (('system-error subr message args data ...)
> ;; e.g. thrown with key 'system-error: ("open-fdes" "~A" ("No such file or directory") (2))
> (format #f (string-append "match-1: subr ~s threw '~s " message " sterror: ~s") subr key args (strerror (car (car data)))))
>
> (('signal any ...)
> ;; not yet implemented
> (format #f "match-2: <NYI:unix signal no> any: ~s" any))
Are you proposing to refactor (ice-9 exceptions) so that it's simpler to
follow a condition message is formed for a given exception type?
Maxim
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#41956: [PATCH] ice-9: exceptions: Properly format the error message.
2020-06-28 4:17 ` Maxim Cournoyer
@ 2020-06-28 4:31 ` Ricardo Wurmus
0 siblings, 0 replies; 12+ messages in thread
From: Ricardo Wurmus @ 2020-06-28 4:31 UTC (permalink / raw)
To: Maxim Cournoyer; +Cc: 41956
Hi Maxim,
>> here’s what I did in the REPL:
>>
>> scheme@(guile-user)> ,m (ice-9 exceptions)
>> scheme@(ice-9 exceptions)> (define (my/guile-system-error-converter key args)
>> (apply (case-lambda
>> ((subr msg-args msg errno . rest)
Here I changed the order: “msg-args” appears before “msg”. I don’t know
why the converter that’s currently in Guile assumes that the message
comes first.
>> scheme@(ice-9 exceptions)> (set! guile-exception-converters (acons 'system-error my/guile-system-error-converter guile-exception-converters))
guile-exception-converters is a lookup table in (ice-9 exceptions). It
associates error keys with converter procedures. Since
canonicalize-path throws a 'system-error I chose to only update the
'system-error association. I didn’t want to affect all the other
converter procedures that end up using the common converter; maybe they
should be affected — I don’t know because I don’t have any test cases
other than canonicalize-path.
> This brings embeds the definition of `guile-common-exceptions' into
> `guile-system-error-converter', with a single change:
>
> (make-exception-with-message msg) --> (apply make-exception-with-message
> msg msg-args)
>
> What is the magic I fail to see?
I cannot parse your sentence, so I’m not sure what you mean.
> Is this fix proper to be merged into the original
> guile-common-exceptions procedure?
I think we should add tests of different exceptions with different keys
to be sure that modifying the common handler doesn’t have any unexpected
side-effects.
--
Ricardo
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#41956: [PATCH] ice-9: exceptions: Properly format the error message.
2020-06-28 4:25 ` Maxim Cournoyer
@ 2020-06-28 18:23 ` Bengt Richter
0 siblings, 0 replies; 12+ messages in thread
From: Bengt Richter @ 2020-06-28 18:23 UTC (permalink / raw)
To: Maxim Cournoyer; +Cc: 41956
Hi Maxim, Ricardo,
On +2020-06-28 00:25:28 -0400, Maxim Cournoyer wrote:
> Hello Bengt,
>
> Bengt Richter <bokr@bokr.com> writes:
>
>
> [...]
>
> > What do you think of using (ice-9 match) to make a universal throwage-formatter,
> > with the idea of making readable top level code for how exceptions become messages on screen?
> >
> > I started a hack to explore the (throw 'whatever any ...) space, beginning like
> >
> > (use-modules (ice-9 match))
> > (define (make-exception-message key rest)
> > (begin
> > (let*((l (cons key rest)))
> > (match l
> > (('system-error subr message args data ...)
> > ;; e.g. thrown with key 'system-error: ("open-fdes" "~A" ("No such file or directory") (2))
> > (format #f (string-append "match-1: subr ~s threw '~s " message " sterror: ~s") subr key args (strerror (car (car data)))))
> >
> > (('signal any ...)
> > ;; not yet implemented
> > (format #f "match-2: <NYI:unix signal no> any: ~s" any))
>
> Are you proposing to refactor (ice-9 exceptions) so that it's simpler to
> follow a condition message is formed for a given exception type?
>
> Maxim
Well, there's probably no catching up with Ludo and Andy, judging from NEWS[1], specifically [2],
so practically speaking, no. I was just floating the idea :)
You may have noticed the "match-1" in e.g.
--8<---------------cut here---------------start------------->8---
> > (format #f (string-append "match-1: subr ~s threw '~s " message " sterror: ~s") subr key args (strerror (car (car data)))))
--8<---------------cut here---------------end--------------->8---
above. The idea there was to find easily the exact format expression that did the output,
(using the tag, to be included per some debug flag or env, but otherwise doing standard error reporting.)
A simple sequence of matches makes it easy to include such debug tags and find them in the code.
(not always easy without tags, I found :)
I guess if match is sequentially implemented like an if-elif*-else chain, it could be too slow without
a generic dispatch to different specialized match sequences, like the dispatch being used now in
--8<---------------cut here---------------start------------->8---
define (convert-guile-exception key args)
(let ((converter (assv-ref guile-exception-converters key)))
(make-exception (or (and converter (converter key args))
(default-guile-exception-converter key args))
(make-exception-with-kind-and-args key args))))
--8<---------------cut here---------------end--------------->8---
┌────────────────────────────────────────────────────────────────────────┐
│ BTW, I wonder if using a hash table and hashv-ref instead off assv-ref │
│ would make any noticeable speed difference for anyone. │
└────────────────────────────────────────────────────────────────────────┘
The commit diffs on match sequences would become a revision history for the fixes that will probably
continue to be necessary, yet the simple surface syntax would be understandable by a newbie.
Actually, looking at the code, I think I will get away while I can,
before I start seeing udev rules in the mix :)
IRL, my next hack might be a (false-if-exception-with-report sexpr) that would ouput to (current-error-port)
if an exception does occur, besides returning #f like the plain false-if-exception.
First a guaranteed (format (current-error-port) "key=<~s> args=~s\n" key args) seen by the handler, then
something more verbose and informative.
Just as a hacking tool, when I want to paper something over, but also want to know what's happening ;-)
Unfortunately, it probably won't help with syntax errors not finding closing quotes or parens and hitting eof ;/
Hope I haven't annoyed anyone.
[1] https://git.savannah.gnu.org/gitweb/?p=guile.git;a=blob_plain;f=NEWS;hb=5e1748f75128107e3a0707b66df5adb95d98437e
(I guess that's up to date, I git cloned the repo and first read the NEWS there.
LOTS going on ;-)
[2] Snip of part I wanted to indicate:
--8<---------------cut here---------------start------------->8---
** Reimplementation of exceptions
Since Guile's origins 25 years ago, `throw' and `catch' have been the
primary exception-handling primitives. However these primitives have
two problems. One is that it's hard to handle exceptions in a
structured way using `catch'. Few people remember what the
corresponding `key' and `args' are that an exception handler would see
in response to a call to `error', for example. In practice, this
results in more generic catch-all exception handling than one might
like.
The other problem is that `throw', `catch', and especially
`with-throw-handler' are quite unlike what the rest of the Scheme world
uses. R6RS and R7RS, for example, have mostly converged on
SRFI-34-style `with-exception-handler' and `raise' primitives, and
encourage the use of SRFI-35-style structured exception objects to
describe the error. Guile's R6RS layer incorporates an adapter between
`throw'/`catch' and structured exception handling, but it didn't apply
to SRFI-34/SRFI-35, and we would have to duplicate it for R7RS.
In light of these considerations, Guile has now changed to make
`with-exception-handler' and `raise-exception' its primitives for
exception handling and defined a hierarchy of R6RS-style exception types
in its core. SRFI-34/35, R6RS, and the exception-handling components of
SRFI-18 (threads) have been re-implemented in terms of this core
functionality. There is also a a compatibility layer that makes it so
that exceptions originating in `throw' can be handled by
`with-exception-hander', and vice-versa for `raise-exception' and
`catch'.
Generally speaking, users will see no difference. The one significant
difference is that users of SRFI-34 will see more exceptions flowing
through their `with-exception-handler'/`guard' forms, because whereas
before they would only see exceptions thrown by SRFI-34, now they will
see exceptions thrown by R6RS, R7RS, or indeed `throw'.
Guile's situation is transitional. Most exceptions are still signalled
via `throw'. These will probably migrate over time to
`raise-exception', while preserving compatibility of course.
See "Exceptions" in the manual, for full details on the new API.
--8<---------------cut here---------------end--------------->8---
--
Regards,
Bengt Richter
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#41956: is this still current ?
2020-06-19 21:33 bug#41956: [PATCH] ice-9: exceptions: Properly format the error message Maxim Cournoyer
2020-06-20 5:46 ` maxim.cournoyer
@ 2021-06-02 7:32 ` Adriano Peluso
2023-11-10 4:17 ` Maxim Cournoyer
1 sibling, 1 reply; 12+ messages in thread
From: Adriano Peluso @ 2021-06-02 7:32 UTC (permalink / raw)
To: 41956
I understand that a overhaul of the exceptions stack intervened while
this bug was open
Is this still current ?
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#41956: is this still current ?
2021-06-02 7:32 ` bug#41956: is this still current ? Adriano Peluso
@ 2023-11-10 4:17 ` Maxim Cournoyer
0 siblings, 0 replies; 12+ messages in thread
From: Maxim Cournoyer @ 2023-11-10 4:17 UTC (permalink / raw)
To: Adriano Peluso; +Cc: Ricardo Wurmus, Bengt Richter, 41956
Hi,
Adriano Peluso <randomlooser@riseup.net> writes:
> I understand that a overhaul of the exceptions stack intervened while
> this bug was open
>
> Is this still current ?
Yes. The affected code hasn't been touched since 2019. To recall, the
reproducer is this:
--8<---------------cut here---------------start------------->8---
(use-modules (srfi srfi-34)
(srfi srfi-35))
(guard (c ((message-condition? c)
(format #t "error: ~a~%" (condition-message c))))
(canonicalize-path "/no/such/path"))
--8<---------------cut here---------------end--------------->8---
or this:
--8<---------------cut here---------------start------------->8---
(use-modules (srfi srfi-34)
(srfi srfi-35))
(guard (c ((message-condition? c)
(format #t "error: ~a~%" (condition-message c))))
;; This is what (canonicalize-path "/do/not/exist) ends up doing:
(throw 'system-error "canonicalize-path" "~A" '("No such file or directory")))
error: ~A
--8<---------------cut here---------------end--------------->8---
--
Thanks,
Maxim
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2023-11-10 4:17 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-06-19 21:33 bug#41956: [PATCH] ice-9: exceptions: Properly format the error message Maxim Cournoyer
2020-06-20 5:46 ` maxim.cournoyer
2020-06-20 18:33 ` Bengt Richter
2020-06-21 3:49 ` Maxim Cournoyer
2020-06-25 10:04 ` Ricardo Wurmus
2020-06-25 16:33 ` Bengt Richter
2020-06-28 4:25 ` Maxim Cournoyer
2020-06-28 18:23 ` Bengt Richter
2020-06-28 4:17 ` Maxim Cournoyer
2020-06-28 4:31 ` Ricardo Wurmus
2021-06-02 7:32 ` bug#41956: is this still current ? Adriano Peluso
2023-11-10 4:17 ` Maxim Cournoyer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).