diff options
Diffstat (limited to 'src/scm/webid-oidc/errors.scm')
-rw-r--r-- | src/scm/webid-oidc/errors.scm | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/src/scm/webid-oidc/errors.scm b/src/scm/webid-oidc/errors.scm index ad8fef3..e6c7a3e 100644 --- a/src/scm/webid-oidc/errors.scm +++ b/src/scm/webid-oidc/errors.scm @@ -104,6 +104,86 @@ (raise-exception ((record-constructor &invalid-signature) key payload signature))) +(define-public ¬-a-jws-header + (make-exception-type + '¬-a-jws-header + &external-error + '(value cause))) + +(define-public (raise-not-a-jws-header value cause) + (raise-exception + ((record-constructor ¬-a-jws-header) value cause))) + +(define-public ¬-a-jws-payload + (make-exception-type + '¬-a-jws-payload + &external-error + '(value cause))) + +(define-public (raise-not-a-jws-payload value cause) + (raise-exception + ((record-constructor ¬-a-jws-payload) value cause))) + +(define-public ¬-a-jws + (make-exception-type + '¬-a-jws + &external-error + '(value cause))) + +(define-public (raise-not-a-jws value cause) + (raise-exception + ((record-constructor ¬-a-jws-payload) value cause))) + +(define-public ¬-in-3-parts + (make-exception-type + '¬-in-3-parts + &external-error + '(string separator))) + +(define-public (raise-not-in-3-parts string separator) + (raise-exception + ((record-constructor ¬-in-3-parts) string separator))) + +(define-public &missing-alist-key + (make-exception-type + '&missing-alist-key + &external-error + '(value key))) + +(define-public (raise-missing-alist-key value key) + (raise-exception + ((record-constructor &missing-alist-key) value key))) + +(define-public &no-matching-key + (make-exception-type + '&no-matching-key + &external-error + '(candidates alg payload signature other-problems))) + +(define-public (raise-no-matching-key candidates alg payload signature) + (raise-exception + ((record-constructor &no-matching-key) candidates alg payload signature))) + +(define-public &cannot-decode-jws + (make-exception-type + '&cannot-decode-jws + &external-error + '(value cause))) + +(define-public (raise-cannot-decode-jws value cause) + (raise-exception + ((record-constructor &cannot-decode-jws) value cause))) + +(define-public &cannot-encode-jws + (make-exception-type + '&cannot-encode-jws + &external-error + '(jws key cause))) + +(define-public (raise-cannot-encode-jws jws key cause) + (raise-exception + ((record-constructor &cannot-encode-jws) jws key cause))) + (define*-public (error->str err #:key (max-depth #f)) (if (record? err) (let* ((type (record-type-descriptor err)) @@ -156,6 +236,30 @@ ((&unsupported-alg) (format #f (G_ "the value ~s does not identify a hash algorithm") (get 'value))) + ((&missing-alist-key) + (format #f (G_ "the value ~s is not an alist or misses key ~s") + (get 'value) (get 'key))) + ((¬-a-jws-header) + (format #f (G_ "the value ~s is not a JWS header (because ~a)") + (get 'value) (recurse (get 'cause)))) + ((¬-a-jws-payload) + (format #f (G_ "the value ~s is not a JWS payload (because ~a)") + (get 'value) (recurse (get 'cause)))) + ((¬-a-jws) + (format #f (G_ "the value ~s is not a JWS (because ~a)") + (get 'value) (recurse (get 'cause)))) + ((¬-in-3-parts) + (format #f (G_ "the string ~s cannot be split in 3 parts with ~s") + (get 'string) (get 'separator))) + ((&no-matching-key) + (format #f (G_ "all key candidates failed to verify signature ~s with algorithm ~s and payload ~a (there were ~a: ~s)") + (get 'signature) (get 'alg) (get 'payload) (length (get 'candidates)) (get 'candidates))) + ((&cannot-decode-jws) + (format #f (G_ "I cannot decode JWS ~a (because ~a)") + (get 'value) (recurse (get 'cause)))) + ((&cannot-encode-jws) + (format #f (G_ "I cannot encode JWS ~a (because ~a)") + (get 'value) (recurse (get 'cause)))) ((&compound-exception) (let ((components (get 'components))) (if (null? components) |