foreign-error custom data alist
Lassi Kortela 27 Jul 2020 08:00 UTC
In the current draft:
(make-foreign-error
'((data . ((arguments . ("not-a-valid-filename" 0 428))
(heritage . "SRFI 170")))))
(foreign-error:data ferr) → alist or #f
Perhaps this would be useful:
(foreign-error:data ferr) -> return the full alist
(foreign-error:data ferr key) -> return the value for key, or #f
It would let people write things like this:
(foreign-error:data ferr 'sqlstate)
(foreign-error:data ferr 'line-number)
(foreign-error:data ferr 'class-code)
The #f defaults for things that are not provided make it easy to chain
things with (or ...) and the like.
We could further make it so that if the value for key 'foo is a lambda,
then (foreign-error:data ferr 'foo) calls the lambda and returns its
value(s). That would make it possible to lazy-load information that is
expensive to compute.