Splitting foreign-error:code Lassi Kortela (27 Jul 2020 06:46 UTC)
Re: Splitting foreign-error:code Lassi Kortela (27 Jul 2020 08:26 UTC)
Re: Splitting foreign-error:code Lassi Kortela (27 Jul 2020 08:51 UTC)
Re: Splitting foreign-error:code John Cowan (28 Jul 2020 19:25 UTC)
Flat vs nested alist Lassi Kortela (27 Jul 2020 23:50 UTC)
Re: Flat vs nested alist Lassi Kortela (27 Jul 2020 23:53 UTC)
Re: Flat vs nested alist John Cowan (28 Jul 2020 03:06 UTC)
Pre-SRFI for property list utilities Lassi Kortela (28 Jul 2020 07:35 UTC)
Re: Pre-SRFI for property list utilities hga@xxxxxx (28 Jul 2020 11:00 UTC)
Plist utilities and SRFI 198 Lassi Kortela (28 Jul 2020 11:08 UTC)
Re: Plist utilities and SRFI 198 John Cowan (28 Jul 2020 18:12 UTC)
plist pre-SRFI hga@xxxxxx (12 Aug 2020 15:14 UTC)
Re: plist pre-SRFI John Cowan (12 Aug 2020 15:21 UTC)
Re: plist pre-SRFI John Cowan (12 Aug 2020 15:53 UTC)
Re: plist pre-SRFI hga@xxxxxx (12 Aug 2020 15:58 UTC)
Re: plist pre-SRFI John Cowan (12 Aug 2020 16:59 UTC)
Re: plist pre-SRFI hga@xxxxxx (12 Aug 2020 17:34 UTC)
Re: plist pre-SRFI John Cowan (12 Aug 2020 19:37 UTC)
Use of SRFI 198 in SRFI 170 hga@xxxxxx (12 Aug 2020 20:04 UTC)

Re: Splitting foreign-error:code Lassi Kortela 27 Jul 2020 08:26 UTC

> It's great that Harold looked into postgres early, since it has
> almost-but-not-quite-numeric error codes. If the world were a simpler
> place, it would be nice to have a `foreign-error:number` procedure that
> returns an integer or #f. But if we used `foreign-error:symbol` for
> almost-numeric codes like '|28P01|, where would we stash the
> definitely-not-numeric identifiers like 'invalid_password?
>
> A practical solution is to have `foreign-error:code` which can return
> either a number or a symbol or #f, as above. Would this be good enough?

Perusing <https://www.postgresql.org/docs/9.4/errcodes-appendix.html>,
it says that Postgres uses so-called "SQLSTATE" codes for its errors.
That explains why they are all 5 characters long and contain letters as
well as numbers. SQLSTATE comes from ANSI SQL and ODBC.

Instead of:

(foreign-error:error-set ferr) -> 'errno
(foreign-error:symbol ferr) -> 'ENOENT
(foreign-error:code ferr) -> 2

(foreign-error:error-set ferr) -> 'postgresql
(foreign-error:symbol ferr) -> 'invalid_password
(foreign-error:code ferr) -> '|28P01|

should we simply have:

(foreign-error:error-set ferr) -> 'errno
(foreign-error:symbol ferr) -> 'ENOENT
(foreign-error:number ferr) -> 2                  ; code => number

(foreign-error:error-set ferr) -> 'postgresql
(foreign-error:symbol ferr) -> 'invalid_password
(foreign-error:number ferr) -> #f                 ; code => number, #f
result
(foreign-error:data ferr 'sqlstate) -> '|28P01|   ; from custom data alist