Re: Splitting foreign-error:code
Lassi Kortela 27 Jul 2020 08:51 UTC
Another possible API: "code" and "mnemonic".
(foreign-error:code ferr) -> 2
(foreign-error:mnemonic ferr) -> 'ENOENT
(foreign-error:code ferr 'sqlstate) -> '|28P01|
(foreign-error:mnemonic ferr) -> 'invalid_password
The term "identifier" is a bit vague. In Scheme, an identifier is like a
symbol, not like a number. But in general parlance, a number can
"identify" an error just as well as a symbol. And SQLSTATE codes can
contain letters, so they need to be represented as Scheme symbols which
are approximately the same as Scheme identifiers. Hence if a
`foreign-error:identifier` did not return the SQLSTATE code, that could
be confusing.
I like "number" better than "code" for clarity - "code" is more abstract
i.e. more vague. But it seems the real world is not simple enough.