summaryrefslogtreecommitdiff
path: root/src/scm/webid-oidc/errors.scm
blob: 60e45f76e5fbb4ef7bcd3a8a02548417add9c2db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
(define-module (webid-oidc errors)
  #:use-module ((webid-oidc stubs) #:prefix stubs:)
  #:use-module (ice-9 exceptions)
  #:use-module (ice-9 optargs)
  #:use-module (ice-9 i18n)
  #:use-module (srfi srfi-19)
  #:use-module (web uri)
  #:use-module (web response))

(define (G_ text)
  (let ((out (gettext text)))
    (if (string=? out text)
        ;; No translation, disambiguate
        (car (reverse (string-split text #\|)))
        out)))

;; This is a collection of all errors that can happen, and a function
;; to log them.

(define-public &not-base64
  (make-exception-type
   '&not-base64
   &external-error
   '(value cause)))

(define-public (raise-not-base64 value cause)
  (raise-exception
   ((record-constructor &not-base64) value cause)))

(define-public &not-json
  (make-exception-type
   '&not-json
   &external-error
   '(value cause)))

(define-public (raise-not-json value cause)
  (raise-exception
   ((record-constructor &not-json) value cause)))

(define-public &not-turtle
  (make-exception-type
   '&not-turtle
   &external-error
   '(value cause)))

(define-public (raise-not-turtle value cause)
  (raise-exception
   ((record-constructor &not-turtle) 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 &not-a-jwk
  (make-exception-type
   '&not-a-jwk
   &external-error
   '(value cause)))

(define-public (raise-not-a-jwk value cause)
  (raise-exception
   ((record-constructor &not-a-jwk) value cause)))

(define-public &not-a-public-jwk
  (make-exception-type
   '&not-a-public-jwk
   &external-error
   '(value cause)))

(define-public (raise-not-a-public-jwk value cause)
  (raise-exception
   ((record-constructor &not-a-public-jwk) value cause)))

(define-public &not-a-private-jwk
  (make-exception-type
   '&not-a-private-jwk
   &external-error
   '(value cause)))

(define-public (raise-not-a-private-jwk value cause)
  (raise-exception
   ((record-constructor &not-a-private-jwk) value cause)))

(define-public &not-a-jwks
  (make-exception-type
   '&not-a-jwks
   &external-error
   '(value cause)))

(define-public (raise-not-a-jwks value cause)
  (raise-exception
   ((record-constructor &not-a-jwks) value cause)))

(define-public &unsupported-alg
  (make-exception-type
   '&unsupported-alg
   &external-error
   '(value)))

(define-public (raise-unsupported-alg value)
  (raise-exception
   ((record-constructor &unsupported-alg) value)))

(define-public &invalid-signature
  (make-exception-type
   '&invalid-signature
   &external-error
   '(key payload signature)))

(define-public (raise-invalid-signature key payload signature)
  (raise-exception
   ((record-constructor &invalid-signature) key payload signature)))

(define-public &not-a-jws-header
  (make-exception-type
   '&not-a-jws-header
   &external-error
   '(value cause)))

(define-public (raise-not-a-jws-header value cause)
  (raise-exception
   ((record-constructor &not-a-jws-header) value cause)))

(define-public &not-a-jws-payload
  (make-exception-type
   '&not-a-jws-payload
   &external-error
   '(value cause)))

(define-public (raise-not-a-jws-payload value cause)
  (raise-exception
   ((record-constructor &not-a-jws-payload) value cause)))

(define-public &not-a-jws
  (make-exception-type
   '&not-a-jws
   &external-error
   '(value cause)))

(define-public (raise-not-a-jws value cause)
  (raise-exception
   ((record-constructor &not-a-jws-payload) value cause)))

(define-public &not-in-3-parts
  (make-exception-type
   '&not-in-3-parts
   &external-error
   '(string separator)))

(define-public (raise-not-in-3-parts string separator)
  (raise-exception
   ((record-constructor &not-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 &request-failed-unexpectedly
  (make-exception-type
   '&request-failed-unexpectedly
   &external-error
   '(response-code response-reason-phrase)))

(define-public (raise-request-failed-unexpectedly
                response-code response-reason-phrase)
  (raise-exception
   ((record-constructor &request-failed-unexpectedly)
    response-code response-reason-phrase)))

(define-public &unexpected-header-value
  (make-exception-type
   '&unexpected-header-value
   &external-error
   '(header value)))

(define-public (raise-unexpected-header-value header value)
  (raise-exception
   ((record-constructor &unexpected-header-value) header value)))

(define-public &unexpected-response
  (make-exception-type
   '&unexpected-response
   &external-error
   '(response cause)))

(define-public (raise-unexpected-response response cause)
  (raise-exception
   ((record-constructor &unexpected-response) response cause)))

(define-public &not-an-oidc-configuration
  (make-exception-type
   '&not-an-oidc-configuration
   &external-error
   '(value cause)))

(define-public (raise-not-an-oidc-configuration value cause)
  (raise-exception
   ((record-constructor &not-an-oidc-configuration) value cause)))

(define-public &incorrect-webid-field
  (make-exception-type
   '&incorrect-webid-field
   &external-error
   '(value)))

(define-public (raise-incorrect-webid-field value)
  (raise-exception
   ((record-constructor &incorrect-webid-field) value)))

(define-public &incorrect-sub-field
  (make-exception-type
   '&incorrect-sub-field
   &external-error
   '(value)))

(define-public (raise-incorrect-sub-field value)
  (raise-exception
   ((record-constructor &incorrect-sub-field) value)))

(define-public &incorrect-iss-field
  (make-exception-type
   '&incorrect-iss-field
   &external-error
   '(value)))

(define-public (raise-incorrect-iss-field value)
  (raise-exception
   ((record-constructor &incorrect-iss-field) value)))

(define-public &incorrect-aud-field
  (make-exception-type
   '&incorrect-aud-field
   &external-error
   '(value)))

(define-public (raise-incorrect-aud-field value)
  (raise-exception
   ((record-constructor &incorrect-aud-field) value)))

(define-public &incorrect-iat-field
  (make-exception-type
   '&incorrect-iat-field
   &external-error
   '(value)))

(define-public (raise-incorrect-iat-field value)
  (raise-exception
   ((record-constructor &incorrect-iat-field) value)))

(define-public &incorrect-exp-field
  (make-exception-type
   '&incorrect-exp-field
   &external-error
   '(value)))

(define-public (raise-incorrect-exp-field value)
  (raise-exception
   ((record-constructor &incorrect-exp-field) value)))

(define-public &incorrect-cnf/jkt-field
  (make-exception-type
   '&incorrect-cnf/jkt-field
   &external-error
   '(value)))

(define-public (raise-incorrect-cnf/jkt-field value)
  (raise-exception
   ((record-constructor &incorrect-cnf/jkt-field) value)))

(define-public &incorrect-client-id-field
  (make-exception-type
   '&incorrect-client-id-field
   &external-error
   '(value)))

(define-public (raise-incorrect-client-id-field value)
  (raise-exception
   ((record-constructor &incorrect-client-id-field) value)))

(define-public &incorrect-redirect-uris-field
  (make-exception-type
   '&incorrect-redirect-uris-field
   &external-error
   '(value)))

(define-public (raise-incorrect-redirect-uris-field value)
  (raise-exception
   ((record-constructor &incorrect-redirect-uris-field) value)))

(define-public &incorrect-typ-field
  (make-exception-type
   '&incorrect-typ-field
   &external-error
   '(value)))

(define-public (raise-incorrect-typ-field value)
  (raise-exception
   ((record-constructor &incorrect-typ-field) value)))

(define-public &incorrect-jwk-field
  (make-exception-type
   '&incorrect-jwk-field
   &external-error
   '(value cause)))

(define-public (raise-incorrect-jwk-field value cause)
  (raise-exception
   ((record-constructor &incorrect-jwk-field) value cause)))

(define-public &incorrect-jti-field
  (make-exception-type
   '&incorrect-jti-field
   &external-error
   '(value)))

(define-public (raise-incorrect-jti-field value)
  (raise-exception
   ((record-constructor &incorrect-jti-field) value)))

(define-public &incorrect-nonce-field
  (make-exception-type
   '&incorrect-nonce-field
   &external-error
   '(value)))

(define-public (raise-incorrect-nonce-field value)
  (raise-exception
   ((record-constructor &incorrect-nonce-field) value)))

(define-public &incorrect-htm-field
  (make-exception-type
   '&incorrect-htm-field
   &external-error
   '(value)))

(define-public (raise-incorrect-htm-field value)
  (raise-exception
   ((record-constructor &incorrect-htm-field) value)))

(define-public &incorrect-htu-field
  (make-exception-type
   '&incorrect-htu-field
   &external-error
   '(value)))

(define-public (raise-incorrect-htu-field value)
  (raise-exception
   ((record-constructor &incorrect-htu-field) value)))

(define-public &not-an-access-token
  (make-exception-type
   '&not-an-access-token
   &external-error
   '(value cause)))

(define-public (raise-not-an-access-token value cause)
  (raise-exception
   ((record-constructor &not-an-access-token) value cause)))

(define-public &not-an-access-token-header
  (make-exception-type
   '&not-an-access-token-header
   &external-error
   '(value cause)))

(define-public (raise-not-an-access-token-header value cause)
  (raise-exception
   ((record-constructor &not-an-access-token-header) value cause)))

(define-public &not-an-access-token-payload
  (make-exception-type
   '&not-an-access-token-payload
   &external-error
   '(value cause)))

(define-public (raise-not-an-access-token-payload value cause)
  (raise-exception
   ((record-constructor &not-an-access-token-payload) value cause)))

(define-public &not-a-dpop-proof
  (make-exception-type
   '&not-a-dpop-proof
   &external-error
   '(value cause)))

(define-public (raise-not-a-dpop-proof value cause)
  (raise-exception
   ((record-constructor &not-a-dpop-proof) value cause)))

(define-public &not-a-dpop-proof-header
  (make-exception-type
   '&not-a-dpop-proof-header
   &external-error
   '(value cause)))

(define-public (raise-not-a-dpop-proof-header value cause)
  (raise-exception
   ((record-constructor &not-a-dpop-proof-header) value cause)))

(define-public &not-a-dpop-proof-payload
  (make-exception-type
   '&not-a-dpop-proof-payload
   &external-error
   '(value cause)))

(define-public (raise-not-a-dpop-proof-payload value cause)
  (raise-exception
   ((record-constructor &not-a-dpop-proof-payload) value cause)))

(define-public &cannot-fetch-issuer-configuration
  (make-exception-type
   '&cannot-fetch-issuer-configuration
   &external-error
   '(issuer cause)))

(define*-public (raise-cannot-fetch-issuer-configuration issuer cause #:key (recoverable? #f))
  (raise-exception
   ((record-constructor &cannot-fetch-issuer-configuration) issuer cause)
   #:continuable? recoverable?))

(define-public &cannot-fetch-jwks
  (make-exception-type
   '&cannot-fetch-jwks
   &external-error
   '(issuer uri cause)))

(define-public (raise-cannot-fetch-jwks issuer uri cause)
  (raise-exception
   ((record-constructor &cannot-fetch-jwks) issuer uri cause)))

(define-public &dpop-method-mismatch
  (make-exception-type
   '&dpop-method-mismatch
   &external-error
   '(signed requested)))

(define-public (raise-dpop-method-mismatch signed requested)
  (raise-exception
   ((record-constructor &dpop-method-mismatch) signed requested)))

(define-public &dpop-uri-mismatch
  (make-exception-type
   '&dpop-uri-mismatch
   &external-error
   '(signed requested)))

(define-public (raise-dpop-uri-mismatch signed requested)
  (raise-exception
   ((record-constructor &dpop-uri-mismatch) signed requested)))

(define-public &dpop-signed-in-future
  (make-exception-type
   '&dpop-signed-in-future
   &external-error
   '(signed requested)))

(define-public (raise-dpop-signed-in-future signed requested)
  (raise-exception
   ((record-constructor &dpop-signed-in-future) signed requested)))

(define-public &dpop-too-old
  (make-exception-type
   '&dpop-too-old
   &external-error
   '(signed requested)))

(define-public (raise-dpop-too-old signed requested)
  (raise-exception
   ((record-constructor &dpop-too-old) signed requested)))

(define-public &dpop-unconfirmed-key
  (make-exception-type
   '&dpop-unconfirmed-key
   &external-error
   '(key expected cause)))

(define-public (raise-dpop-unconfirmed-key key expected cause)
  (raise-exception
   ((record-constructor &dpop-unconfirmed-key) key expected cause)))

(define-public &jti-found
  (make-exception-type
   '&jti-found
   &external-error
   '(jti cause)))

(define-public (raise-jti-found jti cause)
  (raise-exception
   ((record-constructor &jti-found) jti cause)))

(define-public &cannot-decode-access-token
  (make-exception-type
   '&cannot-decode-access-token
   &external-error
   '(value cause)))

(define-public (raise-cannot-decode-access-token value cause)
  (raise-exception
   ((record-constructor &cannot-decode-access-token) value cause)))

(define-public &cannot-encode-access-token
  (make-exception-type
   '&cannot-encode-access-token
   &external-error
   '(access-token key cause)))

(define-public (raise-cannot-encode-access-token access-token key cause)
  (raise-exception
   ((record-constructor &cannot-encode-access-token) access-token key cause)))

(define-public &cannot-decode-dpop-proof
  (make-exception-type
   '&cannot-decode-dpop-proof
   &external-error
   '(value cause)))

(define-public (raise-cannot-decode-dpop-proof value cause)
  (raise-exception
   ((record-constructor &cannot-decode-dpop-proof) value cause)))

(define-public &cannot-encode-dpop-proof
  (make-exception-type
   '&cannot-encode-dpop-proof
   &external-error
   '(dpop-proof key cause)))

(define-public (raise-cannot-encode-dpop-proof dpop-proof key cause)
  (raise-exception
   ((record-constructor &cannot-encode-dpop-proof) dpop-proof key cause)))

(define-public &cannot-fetch-linked-data
  (make-exception-type
   '&cannot-fetch-linked-data
   &external-error
   '(uri cause)))

(define-public (raise-cannot-fetch-linked-data uri cause)
  (raise-exception
   ((record-constructor &cannot-fetch-linked-data) uri cause)))

(define-public &not-a-client-manifest
  (make-exception-type
   '&not-a-client-manifest
   &external-error
   '(value cause)))

(define-public (raise-not-a-client-manifest value cause)
  (raise-exception
   ((record-constructor &not-a-client-manifest) value cause)))

(define-public &unauthorized-redirection-uri
  (make-exception-type
   '&unauthorized-redirection-uri
   &external-error
   '(manifest uri)))

(define-public (raise-unauthorized-redirection-uri manifest uri)
  (raise-exception
   ((record-constructor &unauthorized-redirection-uri) manifest uri)))

(define-public &cannot-serve-public-manifest
  (make-exception-type
   '&cannot-serve-public-manifest
   &external-error
   '()))

(define-public (raise-cannot-serve-public-manifest)
  (raise-exception
   ((record-constructor &cannot-serve-public-manifest))))

(define-public &no-client-manifest-registration
  (make-exception-type
   '&no-client-manifest-registration
   &external-error
   '(id)))

(define-public (raise-no-client-manifest-registration id)
  (raise-exception
   ((record-constructor &no-client-manifest-registration) id)))

(define-public &inconsistent-client-manifest-id
  (make-exception-type
   '&inconsistent-client-manifest-id
   &external-error
   '(id advertised-id)))

(define-public (raise-inconsistent-client-manifest-id id advertised-id)
  (raise-exception
   ((record-constructor &inconsistent-client-manifest-id) id advertised-id)))

(define-public &cannot-fetch-client-manifest
  (make-exception-type
   '&cannot-fetch-client-manifest
   &external-error
   '(id cause)))

(define-public (raise-cannot-fetch-client-manifest id cause)
  (raise-exception
   ((record-constructor &cannot-fetch-client-manifest) id cause)))

(define-public &not-an-authorization-code
  (make-exception-type
   '&not-an-authorization-code
   &external-error
   '(value cause)))

(define-public (raise-not-an-authorization-code value cause)
  (raise-exception
   ((record-constructor &not-an-authorization-code) value cause)))

(define-public &not-an-authorization-code-header
  (make-exception-type
   '&not-an-authorization-code-header
   &external-error
   '(value cause)))

(define-public (raise-not-an-authorization-code-header value cause)
  (raise-exception
   ((record-constructor &not-an-authorization-code-header) value cause)))

(define-public &not-an-authorization-code-payload
  (make-exception-type
   '&not-an-authorization-code-payload
   &external-error
   '(value cause)))

(define-public (raise-not-an-authorization-code-payload value cause)
  (raise-exception
   ((record-constructor &not-an-authorization-code-payload) value cause)))

(define-public &authorization-code-expired
  (make-exception-type
   '&authorization-code-expired
   &external-error
   '(exp current-time)))

(define-public (raise-authorization-code-expired exp current-time)
  (when (integer? exp)
    (set! exp (make-time time-utc 0 exp)))
  (when (time? exp)
    (set! exp (time-utc->date exp)))
  (when (integer? current-time)
    (set! current-time (make-time time-utc 0 current-time)))
  (when (time? current-time)
    (set! current-time (time-utc->date current-time)))
  (raise-exception
   ((record-constructor &authorization-code-expired) exp current-time)))

(define-public &cannot-decode-authorization-code
  (make-exception-type
   '&cannot-decode-authorization-code
   &external-error
   '(value cause)))

(define-public (raise-cannot-decode-authorization-code value cause)
  (raise-exception
   ((record-constructor &cannot-decode-authorization-code) value cause)))

(define-public &cannot-encode-authorization-code
  (make-exception-type
   '&cannot-encode-authorization-code
   &external-error
   '(authorization-code key cause)))

(define-public (raise-cannot-encode-authorization-code authorization-code key cause)
  (raise-exception
   ((record-constructor &cannot-encode-authorization-code) authorization-code key cause)))

(define-public &invalid-refresh-token
  (make-exception-type
   '&invalid-refresh-token
   &external-error
   '(refresh-token)))

(define-public (raise-invalid-refresh-token refresh-token)
  (raise-exception
   ((record-constructor &invalid-refresh-token) refresh-token)))

(define-public &invalid-key-for-refresh-token
  (make-exception-type
   '&invalid-key-for-refresh-token
   &external-error
   '(key jkt)))

(define-public (raise-invalid-key-for-refresh-token key jkt)
  (raise-exception
   ((record-constructor &invalid-key-for-refresh-token) key jkt)))

(define-public &not-an-id-token
  (make-exception-type
   '&not-an-id-token
   &external-error
   '(value cause)))

(define-public (raise-not-an-id-token value cause)
  (raise-exception
   ((record-constructor &not-an-id-token) value cause)))

(define-public &not-an-id-token-header
  (make-exception-type
   '&not-an-id-token-header
   &external-error
   '(value cause)))

(define-public (raise-not-an-id-token-header value cause)
  (raise-exception
   ((record-constructor &not-an-id-token-header) value cause)))

(define-public &not-an-id-token-payload
  (make-exception-type
   '&not-an-id-token-payload
   &external-error
   '(value cause)))

(define-public (raise-not-an-id-token-payload value cause)
  (raise-exception
   ((record-constructor &not-an-id-token-payload) value cause)))

(define-public &cannot-decode-id-token
  (make-exception-type
   '&cannot-decode-id-token
   &external-error
   '(value cause)))

(define-public (raise-cannot-decode-id-token value cause)
  (raise-exception
   ((record-constructor &cannot-decode-id-token) value cause)))

(define-public &cannot-encode-id-token
  (make-exception-type
   '&cannot-encode-id-token
   &external-error
   '(id-token key cause)))

(define-public (raise-cannot-encode-id-token id-token key cause)
  (raise-exception
   ((record-constructor &cannot-encode-id-token) id-token key cause)))

(define-public &unknown-client-locale
  (make-exception-type
   '&unknown-client-locale
   &external-error
   '(web-locale c-locale)))

(define-public (raise-unknown-client-locale web-locale c-locale)
  (raise-exception
   ((record-constructor &unknown-client-locale) web-locale c-locale)
   #:continuable? #t))

(define-public &unsupported-grant-type
  (make-exception-type
   '&unsupported-grant-type
   &external-error
   '(value)))

(define-public (raise-unsupported-grant-type value)
  (raise-exception
   ((record-constructor &unsupported-grant-type) value)))

(define-public &no-authorization-code
  (make-exception-type
   '&no-authorization-code
   &external-error
   '(value)))

(define-public (raise-no-authorization-code)
  (raise-exception
   ((record-constructor &no-authorization-code))))

(define-public &no-refresh-token
  (make-exception-type
   '&no-refresh-token
   &external-error
   '(value)))

(define-public (raise-no-refresh-token)
  (raise-exception
   ((record-constructor &no-refresh-token))))

(define-public &unconfirmed-provider
  (make-exception-type
   '&unconfirmed-provider
   &external-error
   '(subject provider)))

(define-public (raise-unconfirmed-provider subject provider)
  (raise-exception
   ((record-constructor &unconfirmed-provider) subject provider)))

(define-public &neither-identity-provider-nor-webid
  (make-exception-type
   '&neither-identity-provider-nor-webid
   &external-error
   '(uri why-not-identity-provider why-not-webid)))

(define-public (raise-neither-identity-provider-nor-webid uri why-not-identity-provider why-not-webid)
  (raise-exception
   ((record-constructor &neither-identity-provider-nor-webid)
    uri why-not-identity-provider why-not-webid)))

(define-public &token-request-failed
  (make-exception-type
   '&token-request-failed
   &external-error
   '(cause)))

(define-public (raise-token-request-failed cause)
  (raise-exception
   ((record-constructor &token-request-failed) cause)))

(define-public &profile-not-found
  (make-exception-type
   '&profile-not-found
   &external-error
   '(webid iss dir)))

(define-public (raise-profile-not-found webid iss dir)
  (raise-exception
   ((record-constructor &profile-not-found) webid iss dir)))

(define-public &no-provider-candidates
  (make-exception-type
   '&no-provider-candidates
   &external-error
   '(webid causes)))

(define-public (raise-no-provider-candidates webid causes)
  (raise-exception
   ((record-constructor &no-provider-candidates) webid causes)))

;; Server-side exceptions

(define-exception-type
  &path-not-found
  &external-error
  make-path-not-found
  path-not-found?
  (path path-not-found-path))

(export &path-not-found
        make-path-not-found
        path-not-found?
        path-not-found-path)

(define-exception-type
  &uri-slash-semantics-error
  &external-error
  make-uri-slash-semantics-error
  uri-slash-semantics-error?
  (path uri-slash-semantics-error-path)
  (expected-path uri-slash-semantics-error-expected-path))

(export &uri-slash-semantics-error
        make-uri-slash-semantics-error
        uri-slash-semantics-error?
        uri-slash-semantics-error-path
        uri-slash-semantics-error-expected-path)

(define-exception-type
  &cannot-delete-root
  &external-error
  make-cannot-delete-root
  cannot-delete-root?)

(export &cannot-delete-root
        make-cannot-delete-root
        cannot-delete-root?)

(define-exception-type
  &container-not-empty
  &external-error
  make-container-not-empty
  container-not-empty?
  (path container-not-empty-path))

(export &container-not-empty
        make-container-not-empty
        container-not-empty?
        container-not-empty-path)

(define*-public (error->str err #:key (max-depth #f))
  (if (record? err)
      (let* ((type (record-type-descriptor err))
             (get
              (lambda (slot)
                ((record-accessor type slot) err)))
             (recurse
              (if (eqv? max-depth 0)
                  (lambda (err) (G_ "that’s how it is"))
                  (lambda (err)
                    (error->str err #:max-depth (and max-depth (- max-depth 1)))))))
        (case (record-type-name type)
          ((&not-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))))
          ((&not-turtle)
           (format #f (G_ "the value ~s is not Turtle (because ~a)")
                   (get 'value) (recurse (get 'cause))))
          ((&unsupported-crv)
           (format #f (G_ "the value ~s does not identify an elleptic curve")
                   (get 'crv)))
          ((&not-a-jwk)
           (let ((cause (get 'cause)))
             (if cause
                 (format #f (G_ "the value ~s does not identify a JWK (because ~a)")
                         (get 'value) (recurse cause))
                 (format #f (G_ "the value ~s does not identify a JWK")
                         (get 'value)))))
          ((&not-a-public-jwk)
           (let ((cause (get 'cause)))
             (if cause
                 (format #f (G_ "the value ~s does not identify a public JWK (because ~a)")
                         (get 'value) (recurse cause))
                 (format #f (G_ "the value ~s does not identify a public JWK")
                         (get 'value)))))
          ((&not-a-private-jwk)
           (let ((cause (get 'cause)))
             (if cause
                 (format #f (G_ "the value ~s does not identify a private JWK (because ~a)")
                         (get 'value) cause)
                 (format #f (G_ "the value ~s does not identify a private JWK")
                         (get 'value)))))
          ((&not-a-jwks)
           (let ((cause (get 'cause)))
             (if cause
                 (format #f (G_ "the value ~s does not identify a JWKS (because ~a)")
                         (get 'value) (recurse cause))
                 (format #f (G_ "the value ~s does not identify a JWKS")
                         (get 'value)))))
          ((&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)))
          ((&not-a-jws-header)
           (format #f (G_ "the value ~s is not a JWS header (because ~a)")
                   (get 'value) (recurse (get 'cause))))
          ((&not-a-jws-payload)
           (format #f (G_ "the value ~s is not a JWS payload (because ~a)")
                   (get 'value) (recurse (get 'cause))))
          ((&not-a-jws)
           (format #f (G_ "the value ~s is not a JWS (because ~a)")
                   (get 'value) (recurse (get 'cause))))
          ((&not-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))))
          ((&response-failed-unexpectedly)
           (format #f (G_ "the server request unexpectedly failed with code ~a and reason phrase ~s")
                   (get 'response-code) (get 'response-reason-phrase)))
          ((&unexpected-header-value)
           (let ((value (get 'value)))
             (if value
                 (format #f (G_ "the header ~a should not have the value ~s")
                         (get 'header) value)
                 (format #f (G_ "the header ~a should be present")
                         (get 'header)))))
          ((&unexpected-response)
           (format #f (G_ "the server response wasn't expected: ~s (because ~a)")
                   (call-with-output-string
                     (lambda (port)
                       (write-response (get 'response) port)))
                   (recurse (get 'cause))))
          ((&not-an-oidc-configuration)
           (format #f (G_ "the value ~s is not an OIDC configuration (because ~a)")
                   (get 'value) (recurse (get 'cause))))
          ((&incorrect-webid-field)
           (let ((value (get 'value)))
             (if value
                 (format #f (G_ "the webid field is incorrect: ~s") value)
                 (format #f (G_ "the webid field is missing")))))
          ((&incorrect-sub-field)
           (let ((value (get 'value)))
             (if value
                 (format #f (G_ "the sub field is incorrect: ~s") value)
                 (format #f (G_ "the sub field is missing")))))
          ((&incorrect-iss-field)
           (let ((value (get 'value)))
             (if value
                 (format #f (G_ "the iss field is incorrect: ~s") value)
                 (format #f (G_ "the iss field is missing")))))
          ((&incorrect-aud-field)
           (let ((value (get 'value)))
             (if value
                 (format #f (G_ "the aud field is incorrect: ~s") value)
                 (format #f (G_ "the aud field is missing")))))
          ((&incorrect-iat-field)
           (let ((value (get 'value)))
             (if value
                 (format #f (G_ "the iat field is incorrect: ~s") value)
                 (format #f (G_ "the iat field is missing")))))
          ((&incorrect-exp-field)
           (let ((value (get 'value)))
             (if value
                 (format #f (G_ "the exp field is incorrect: ~s") value)
                 (format #f (G_ "the exp field is missing")))))
          ((&incorrect-cnf/jkt-field)
           (let ((value (get 'value)))
             (if value
                 (format #f (G_ "the cnf/jkt field is incorrect: ~s") value)
                 (format #f (G_ "the cnf/jkt field is missing")))))
          ((&incorrect-client-id-field)
           (let ((value (get 'value)))
             (if value
                 (format #f (G_ "the client-id field is incorrect: ~s") value)
                 (format #f (G_ "the client-id field is missing")))))
          ((&incorrect-redirect-uris-field)
           (let ((value (get 'value)))
             (if value
                 (format #f (G_ "the redirect_uris field is incorrect: ~s") value)
                 (format #f (G_ "the redirect_uris field is missing")))))
          ((&incorrect-typ-field)
           (let ((value (get 'value)))
             (if value
                 (format #f (G_ "the typ field is incorrect: ~s") value)
                 (format #f (G_ "the typ field is missing")))))
          ((&incorrect-jwk-field)
           (let ((value (get 'value)))
             (if value
                 (format #f (G_ "the jwk field is incorrect: ~s (because ~a)")
                         value (recurse (get 'cause)))
                 (format #f (G_ "the jwk field is missing")))))
          ((&incorrect-jti-field)
           (let ((value (get 'value)))
             (if value
                 (format #f (G_ "the jti field is incorrect: ~s") value)
                 (format #f (G_ "the jti field is missing")))))
          ((&incorrect-nonce-field)
           (let ((value (get 'value)))
             (if value
                 (format #f (G_ "the nonce field is incorrect: ~s") value)
                 (format #f (G_ "the nonce field is missing")))))
          ((&incorrect-htm-field)
           (let ((value (get 'value)))
             (if value
                 (format #f (G_ "the htm field is incorrect: ~s") value)
                 (format #f (G_ "the htm field is missing")))))
          ((&incorrect-htu-field)
           (let ((value (get 'value)))
             (if value
                 (format #f (G_ "the htu field is incorrect: ~s") value)
                 (format #f (G_ "the htu field is missing")))))
          ((&not-an-access-token)
           (format #f (G_ "~s is not an access token (because ~a)")
                   (get 'value) (recurse (get 'cause))))
          ((&not-an-access-token-header)
           (format #f (G_ "~s is not an access token header (because ~a)")
                   (get 'value) (recurse (get 'cause))))
          ((&not-an-access-token-payload)
           (format #f (G_ "~s is not an access token payload (because ~a)")
                   (get 'value) (recurse (get 'cause))))
          ((&not-a-dpop-proof)
           (format #f (G_ "~s is not a DPoP proof (because ~a)")
                   (get 'value) (recurse (get 'cause))))
          ((&not-a-dpop-proof-header)
           (format #f (G_ "~s is not a DPoP proof header (because ~a)")
                   (get 'value) (recurse (get 'cause))))
          ((&not-a-dpop-proof-payload)
           (format #f (G_ "~s is not a DPoP proof payload (because ~a)")
                   (get 'value) (recurse (get 'cause))))
          ((&cannot-fetch-issuer-configuration)
           (format #f (G_ "I cannot fetch the issuer configuration of ~a (because ~a)")
                   (let ((iss (get 'issuer)))
                     (when (uri? iss)
                       (set! iss (uri->string iss)))
                     iss)
                   (recurse (get 'cause))))
          ((&cannot-fetch-jwks)
           (format #f (G_ "I cannot fetch the JWKS of ~a at ~a (because ~a)")
                   (let ((iss (get 'issuer)))
                     (when (uri? iss)
                       (set! iss (uri->string iss)))
                     iss)
                   (let ((uri (get 'uri)))
                     (when (uri? uri)
                       (set! uri (uri->string uri)))
                     uri)
                   (recurse (get 'cause))))
          ((&dpop-method-mismatch)
           (format #f (G_ "the HTTP method is signed for ~s, but ~s was requested")
                   (get 'signed) (get 'requested)))
          ((&dpop-uri-mismatch)
           (format #f (G_ "the HTTP uri is signed for ~a, but ~a was requested")
                   (uri->string (get 'signed)) (uri->string (get 'requested))))
          ((&dpop-signed-in-future)
           (format #f (G_ "the date is ~a, but the DPoP proof is signed in the future at ~a")
                   (time-second (date->time-utc (get 'signed)))
                   (time-second (date->time-utc (get 'requested)))))
          ((&dpop-too-old)
           (format #f (G_ "the date is ~a, but the DPoP proof was signed too long ago at ~a")
                   (time-second (date->time-utc (get 'signed)))
                   (time-second (date->time-utc (get 'requested)))))
          ((&dpop-unconfirmed-key)
           (let ((key (get 'key))
                 (expected (get 'expected))
                 (cause (get 'cause)))
             (cond
              (expected
               (format #f (G_ "the key ~s does not hash to ~a") key expected))
              (cause
               (format #f (G_ "the key confirmation of ~s failed (because ~a)") key (recurse cause)))
              (else
               (format #f (G_ "the key confirmation of ~s failed") key)))))
          ((&jti-found)
           (format #f (G_ "the jti ~s has already been found (because ~a)")
                   (get 'jti) (recurse (get 'cause))))
          ((&cannot-decode-access-token)
           (format #f (G_ "I cannot decode ~s as an access token (because ~a)")
                   (get 'value) (recurse (get 'cause))))
          ((&cannot-encode-access-token)
           (format #f (G_ "I cannot encode ~s as an access token with key ~s (because ~a)")
                   (get 'access-token) (get 'key) (recurse (get 'cause))))
          ((&cannot-decode-dpop-proof)
           (format #f (G_ "I cannot decode ~s as a DPoP proof (because ~a)")
                   (get 'value) (recurse (get 'cause))))
          ((&cannot-encode-dpop-proof)
           (format #f (G_ "I cannot encode ~s as a DPoP proof (because ~a)")
                   (get 'value) (recurse (get 'cause))))
          ((&cannot-fetch-linked-data)
           (format #f (G_ "I could not fetch a RDF graph at ~a (because ~a)")
                   (uri->string (get 'uri)) (recurse (get 'cause))))
          ((&not-a-client-manifest)
           (format #f (G_ "~s is not a client manifest (because ~a)")
                   (get 'value) (recurse (get 'cause))))
          ((&unauthorized-redirection-uri)
           (format #f (G_ "~s does not authorize redirection URI ~a")
                   (get 'manifest) (uri->string (get 'uri))))
          ((&cannot-serve-public-manifest)
           (format #f (G_ "I cannot serve a public manifest")))
          ((&no-client-manifest-registration)
           (format #f (G_ "~a does not have a client manifest registration triple")
                   (uri->string (get 'id))))
          ((&inconsistent-client-manifest-id)
           (format #f (G_ "the client manifest at ~a is advertised for ~a")
                   (uri->string (get 'id)) (uri->string (get 'advertised-id))))
          ((&cannot-fetch-client-manifest)
           (format #f (G_ "I could not fetch the client manifest of ~a (because ~a)")
                   (uri->string (get 'id)) (recurse (get 'cause))))
          ((&not-an-authorization-code)
           (format #f (G_ "~s is not an authorization code (because ~a)")
                   (get 'value) (recurse (get 'cause))))
          ((&not-an-authorization-code-header)
           (format #f (G_ "~s is not an authorization code header (because ~a)")
                   (get 'value) (recurse (get 'cause))))
          ((&not-an-authorization-code-payload)
           (format #f (G_ "~s is not an authorization code payload (because ~a)")
                   (get 'value) (recurse (get 'cause))))
          ((&authorization-code-expired)
           (format #f (G_ "the current time is ~a, and the authorization code expired at ~a")
                   (time-second (date->time-utc (get 'current-time)))
                   (time-second (date->time-utc (get 'exp)))))
          ((&cannot-decode-authorization-code)
           (format #f (G_ "I cannot decode ~s as an authorization code (because ~a)")
                   (get 'value) (recurse (get 'cause))))
          ((&cannot-encode-authorization-code)
           (format #f (G_ "I cannot encode ~s as an authorization code (because ~a)")
                   (get 'value) (recurse (get 'cause))))
          ((&invalid-refresh-token)
           (format #f (G_ "there is no such refresh token as ~s")
                   (get 'refresh-token)))
          ((&invalid-key-for-refresh-token)
           (format #f (G_ "the refresh token is bound to a key confirmed as ~s, but it is used with key ~s")
                   (get 'jkt) (get 'key)))
          ((&cannot-decode-id-token)
           (format #f (G_ "I cannot decode ~s as an ID token (because ~a)")
                   (get 'value) (recurse (get 'cause))))
          ((&cannot-encode-id-token)
           (format #f (G_ "I cannot encode ~s as an ID token (because ~a)")
                   (get 'value) (recurse (get 'cause))))
          ((&unsupported-grant-type)
           (format #f (G_ "the grant type ~s is not supported")
                   (get 'value)))
          ((&no-authorization-code)
           (format #f (G_ "there is no authorization code in the request")))
          ((&no-refresh-token)
           (format #f (G_ "there is no refresh token in the request")))
          ((&not-an-id-token)
           (format #f (G_ "~s is not an ID token (because ~a)")
                   (get 'value) (recurse (get 'cause))))
          ((&not-an-id-token-header)
           (format #f (G_ "~s is not an ID token header (because ~a)")
                   (get 'value) (recurse (get 'cause))))
          ((&not-an-id-token-payload)
           (format #f (G_ "~s is not an ID token payload (because ~a)")
                   (get 'value) (recurse (get 'cause))))
          ((&unknown-client-locale)
           (format #f (G_ "I couldn’t set the locale to ~s as an approximation of the client locale ~s")
                   (get 'c-locale) (get 'web-locale)))
          ((&unconfirmed-provider)
           (format #f (G_ "~s does not admit ~s as an identity provider")
                   (get 'subject) (get 'provider)))
          ((&neither-identity-provider-nor-webid)
           (format #f (G_ "~a is neither an identity provider (because ~a) nor a webid (because ~a)")
                   (uri->string (get 'uri))
                   (recurse (get 'why-not-identity-provider))
                   (recurse (get 'why-not-webid))))
          ((&token-request-failed)
           (format #f (G_ "the token request failed (because ~a)")
                   (recurse (get 'cause))))
          ((&profile-not-found)
           (format #f (G_ "you don’t have a refresh token for identity ~a certified by ~a in ~s")
                   (uri->string (get 'webid))
                   (uri->string (get 'iss))
                   (get 'dir)))
          ((&no-provider-candidates)
           (format #f (G_ "all identity provider candidates for ~a failed: ~a")
                   (uri->string (get 'webid))
                   (string-join
                    (map (lambda (cause)
                           (format #f (G_ "~s failed (because ~a)")
                                   (uri->string (car cause)) (recurse (cdr cause))))
                         (get 'causes))
                    (G_ ", "))))
          ((&path-not-found)
           (format #f (G_ "no resource has been found to serve URI path ~s")
                   (get 'path)))
          ((&uri-slash-semantics-error)
           (format #f (G_ "no resource has been found to serve URI path ~s, but ~s exists")
                   (get 'path) (get 'expected-path)))
          ((&cannot-delete-root)
           (format #f (G_ "the root storage cannot be deleted")))
          ((&container-not-empty)
           (format #f (G_ "the container ~s should be emptied before being deleted")
                   (get 'path)))
          ((&compound-exception)
           (let ((components (get 'components)))
             (if (null? components)
                 (G_ "that’s it")
                 (if (null? (cdr components))
                     (recurse (car components))
                     (if (null? (cddr components))
                         (format #f (G_ "~a and ~a")
                                 (recurse (car components))
                                 (recurse (cadr components)))
                         (format #f (G_ "~a, ~a")
                                 (recurse (car components))
                                 (recurse (apply make-exception (cdr components)))))))))
          ((&invalid-signature)
           (format #f (G_ "the signature ~a does not match key ~s with payload ~a")
                   (get 'signature) (get 'key) (get 'payload)))
          ((&undefined-variable)
           (G_ "there is an undefined variable"))
          ((&origin)
           (format #f (G_ "the origin is ~a")
                   (exception-origin err)))
          ((&message)
           (format #f (G_ "a message is attached: ~a")
                   (exception-message err)))
          ((&irritants)
           (format #f (G_ "the values ~s are problematic")
                   (exception-irritants err)))
          ((&exception-with-kind-and-args)
           (format #f (G_ "there is a kind and args")))
          ((&assertion-failure)
           (format #f (G_ "there is an assertion failure")))
          ((&quit-exception)
           (format #f (G_ "the program quits with code ~a")
                   (get 'code)))
          ((&non-continuable)
           (format #f (G_ "the program cannot recover from this exception")))
          ((&error)
           (format #f (G_ "there is an error")))
          (else
           (error (format #f (G_ "Unhandled exception type ~a.")
                          (record-type-name type))))))
      (format #f "~a" err)))