1 local enum error_type |
|
2 "auth" |
|
3 "cancel" |
|
4 "continue" |
|
5 "modify" |
|
6 "wait" |
|
7 end |
|
8 |
|
9 local enum error_condition |
|
10 "bad-request" |
|
11 "conflict" |
|
12 "feature-not-implemented" |
|
13 "forbidden" |
|
14 "gone" |
|
15 "internal-server-error" |
|
16 "item-not-found" |
|
17 "jid-malformed" |
|
18 "not-acceptable" |
|
19 "not-allowed" |
|
20 "not-authorized" |
|
21 "policy-violation" |
|
22 "recipient-unavailable" |
|
23 "redirect" |
|
24 "registration-required" |
|
25 "remote-server-not-found" |
|
26 "remote-server-timeout" |
|
27 "resource-constraint" |
|
28 "service-unavailable" |
|
29 "subscription-required" |
|
30 "undefined-condition" |
|
31 "unexpected-request" |
|
32 end |
|
33 |
|
34 local record protoerror |
|
35 type : error_type |
|
36 condition : error_condition |
|
37 text : string |
|
38 code : integer |
|
39 end |
|
40 |
|
41 local record Error |
|
42 type : error_type |
|
43 condition : error_condition |
|
44 text : string |
|
45 code : integer |
|
46 context : { any : any } |
|
47 source : string |
|
48 end |
|
49 |
|
50 local type compact_registry_item = { string, string, string, string } |
|
51 local type compact_registry = { compact_registry_item } |
|
52 local type registry = { string : protoerror } |
|
53 local type context = { string : any } |
|
54 |
|
55 local record error_registry_wrapper |
|
56 source : string |
|
57 registry : registry |
|
58 new : function (string, context) : Error |
|
59 coerce : function (any, string) : any, Error |
|
60 wrap : function (Error) : Error |
|
61 wrap : function (string, context) : Error |
|
62 is_error : function (any) : boolean |
|
63 end |
|
64 |
|
65 local record lib |
|
66 record configure_opt |
|
67 auto_inject_traceback : boolean |
|
68 end |
|
69 new : function (protoerror, context, { string : protoerror }, string) : Error |
|
70 init : function (string, string, registry | compact_registry) : error_registry_wrapper |
|
71 init : function (string, registry | compact_registry) : error_registry_wrapper |
|
72 is_error : function (any) : boolean |
|
73 coerce : function (any, string) : any, Error |
|
74 from_stanza : function (table, context, string) : Error |
|
75 configure : function |
|
76 end |
|
77 |
|
78 return lib |
|