bug#41956: [PATCH] ice-9: exceptions: Properly format the error message.

Bengt Richter <[email protected]>
Newsgroups gmane.lisp.guile.bugs
Message-ID <20200620183334.GA9490@LionPure>
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, [email protected] wrote:
> Maxim Cournoyer <[email protected]> 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.