From c1940e2d9c926374e581cef7b47082b62e76f4ca Mon Sep 17 00:00:00 2001 From: Vivien Kraus Date: Wed, 1 Jan 2020 00:00:00 +0100 Subject: Add a strip function --- src/scm/webid-oidc/errors.scm | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'src/scm/webid-oidc/errors.scm') diff --git a/src/scm/webid-oidc/errors.scm b/src/scm/webid-oidc/errors.scm index 9d08ed5..27dc6e2 100644 --- a/src/scm/webid-oidc/errors.scm +++ b/src/scm/webid-oidc/errors.scm @@ -26,7 +26,7 @@ (define-public ¬-json (make-exception-type - 'not-json + '¬-json &external-error '(value cause))) @@ -34,6 +34,26 @@ (raise-exception ((record-constructor ¬-json) value cause))) +(define-public &unsupported-crv + (make-exception-type + '&unsupported-crv + &external-error + '(crv))) + +(define-public (raise-unsupported-crv crv) + (raise-exception + ((record-constructor &unsupported-crv) crv))) + +(define-public ¬-a-jwk + (make-exception-type + '¬-a-jwk + &external-error + '(value cause))) + +(define-public (raise-not-a-jwk value cause) + (raise-exception + ((record-constructor ¬-a-jwk) value cause))) + (define*-public (error->str err #:key (max-depth #f)) (if (record? err) (let* ((type (record-type-descriptor err)) @@ -49,9 +69,19 @@ ((¬-base64) (format #f (G_ "the value ~s is not a base64 string (because ~a)") (get 'value) (recurse (get 'cause)))) - ((not-json) + ((¬-json) (format #f (G_ "the value ~s is not JSON (because ~a)") (get 'value) (recurse (get 'cause)))) + ((&unsupported-crv) + (format #f (G_ "the value ~s does not identify an elleptic curve") + (get 'crv))) + ((¬-a-jwk) + (let ((cause (get 'cause))) + (if cause + (format #f (G_ "the value ~s does not identify a JWK (because ~a)") + (get 'value) cause) + (format #f (G_ "the value ~s does not identify a JWK") + (get 'value))))) ((&compound-exception) (let ((components (get 'components))) (if (null? components) -- cgit v1.2.3