Hello, I would like to dispatch exceptions based on errno, in particular to return #f on ENOENT, and re-raise the exception otherwise. My current (working as far as I can tell) solution is:
--8<---------------cut here---------------start------------->8---
(with-exception-handler
(λ (exc)
(and (not (= ENOENT (car (list-ref (exception-args exc) 3))))
(raise-exception exc)))
(λ ()
(with-input-from-file (path realm query) read))
#:unwind? #t
#:unwind-for-type 'system-error)
--8<---------------cut here---------------end--------------->8---
However, I do not consider it very elegant, especially this part:
--8<---------------cut here---------------start------------->8---
(car (list-ref (exception-args exc) 3))
--8<---------------cut here---------------end--------------->8---
Is there better way to do this?
Second question is how to print exceptions including a stack trace. I
noticed there is display-error, however it takes a frame argument and I
am not sure where to get it. I did not found any exception-frame
procedure. However since the default exception-handle *is* able to
print the stack on exception, I assume it is possible. Any tips?
Thanks,
Tomas
--
There are only two hard things in Computer Science:
cache invalidation, naming things and off-by-one errors.
signature.asc
Description: PGP signature
