diff options
author | Vivien Kraus <vivien@planete-kraus.eu> | 2021-04-26 13:11:11 +0200 |
---|---|---|
committer | Vivien Kraus <vivien@planete-kraus.eu> | 2021-06-19 15:44:24 +0200 |
commit | fadfd29ceb64c8a60a369c0d3f225cfd0f46157b (patch) | |
tree | 251fc2bc5096061acc60253b196ec7b6de0e75a2 /src/scm/webid-oidc/errors.scm | |
parent | fbdb021dc275080f1e817317306defc354828715 (diff) |
Export a JSON API that is compatible with SRFI-180
SRFI-180 represents JSON objects as alists from symbols to values,
while guile-json represents them as alists from strings to values.
Since alists are everywhere in the API, we need them to be as standard
as possible. So, we need them in SRFI-180 format.
Diffstat (limited to 'src/scm/webid-oidc/errors.scm')
-rw-r--r-- | src/scm/webid-oidc/errors.scm | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/scm/webid-oidc/errors.scm b/src/scm/webid-oidc/errors.scm index 98859c9..9d08ed5 100644 --- a/src/scm/webid-oidc/errors.scm +++ b/src/scm/webid-oidc/errors.scm @@ -24,6 +24,16 @@ (raise-exception ((record-constructor ¬-base64) value cause))) +(define-public ¬-json + (make-exception-type + 'not-json + &external-error + '(value cause))) + +(define-public (raise-not-json value cause) + (raise-exception + ((record-constructor ¬-json) value cause))) + (define*-public (error->str err #:key (max-depth #f)) (if (record? err) (let* ((type (record-type-descriptor err)) @@ -39,6 +49,9 @@ ((¬-base64) (format #f (G_ "the value ~s is not a base64 string (because ~a)") (get 'value) (recurse (get 'cause)))) + ((not-json) + (format #f (G_ "the value ~s is not JSON (because ~a)") + (get 'value) (recurse (get 'cause)))) ((&compound-exception) (let ((components (get 'components))) (if (null? components) |