unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: Ricardo Wurmus <rekado@elephly.net>
To: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Cc: 41956@debbugs.gnu.org
Subject: bug#41956: [PATCH] ice-9: exceptions: Properly format the error message.
Date: Thu, 25 Jun 2020 12:04:27 +0200	[thread overview]
Message-ID: <87bll7qx5g.fsf@elephly.net> (raw)
In-Reply-To: <87r1u9m62o.fsf@gmail.com>


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





  reply	other threads:[~2020-06-25 10:04 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87bll7qx5g.fsf@elephly.net \
    --to=rekado@elephly.net \
    --cc=41956@debbugs.gnu.org \
    --cc=maxim.cournoyer@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).