* Patch for printing of system-error exceptions
@ 2012-07-28 14:39 Krister Svanlund
2013-01-21 12:15 ` Andy Wingo
0 siblings, 1 reply; 2+ messages in thread
From: Krister Svanlund @ 2012-07-28 14:39 UTC (permalink / raw)
To: guile-devel
[-- Attachment #1: Type: text/plain, Size: 176 bytes --]
Wrote a really small patch for proper printing of system-error
exceptions. I'm fairly certain it should work for most cases where it
is thrown by guile.
The patch is attached
[-- Attachment #2: guile-system-error-printer.patch --]
[-- Type: application/octet-stream, Size: 1445 bytes --]
diff --git a/module/ice-9/boot-9.scm b/module/ice-9/boot-9.scm
index 14dfb60..e5603d2 100644
--- a/module/ice-9/boot-9.scm
+++ b/module/ice-9/boot-9.scm
@@ -925,6 +925,14 @@ information is unavailable."
(_ (default-printer)))
args))
+ (define (system-error-printer port key args default-printer)
+ (apply (case-lambda
+ ((func fmt reasons _)
+ (format port "System error:\n")
+ (apply format port fmt reasons))
+ (_ (default-printer)))
+ args))
+
(define (getaddrinfo-error-printer port key args default-printer)
(format port "In procedure getaddrinfo: ~a" (gai-strerror (car args))))
@@ -941,12 +949,13 @@ information is unavailable."
(set-exception-printer! 'regular-expression-syntax scm-error-printer)
(set-exception-printer! 'signal scm-error-printer)
(set-exception-printer! 'stack-overflow scm-error-printer)
- (set-exception-printer! 'system-error scm-error-printer)
(set-exception-printer! 'try-again scm-error-printer)
(set-exception-printer! 'unbound-variable scm-error-printer)
(set-exception-printer! 'wrong-number-of-args scm-error-printer)
(set-exception-printer! 'wrong-type-arg scm-error-printer)
+ (set-exception-printer! 'system-error system-error-printer)
+
(set-exception-printer! 'syntax-error syntax-error-printer)
(set-exception-printer! 'getaddrinfo-error getaddrinfo-error-printer))
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: Patch for printing of system-error exceptions
2012-07-28 14:39 Patch for printing of system-error exceptions Krister Svanlund
@ 2013-01-21 12:15 ` Andy Wingo
0 siblings, 0 replies; 2+ messages in thread
From: Andy Wingo @ 2013-01-21 12:15 UTC (permalink / raw)
To: Krister Svanlund; +Cc: guile-devel
Hi Krister,
On Sat 28 Jul 2012 16:39, Krister Svanlund <krister.svanlund@gmail.com> writes:
> + (define (system-error-printer port key args default-printer)
> + (apply (case-lambda
> + ((func fmt reasons _)
> + (format port "System error:\n")
> + (apply format port fmt reasons))
> + (_ (default-printer)))
> + args))
> +
Is this actually an improvement? We miss out on the "func" argument.
Can you show examples before and after this change?
Andy
--
http://wingolog.org/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-01-21 12:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-28 14:39 Patch for printing of system-error exceptions Krister Svanlund
2013-01-21 12:15 ` Andy Wingo
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).