Comparison

teal-src/util/error.d.tl @ 11432:113f3912c7cb

util: Add Teal interface definition files Enables writing code in Teal that is aware of the interfaces and function prototypes in these other utils. Could also be used to do type checks on Lua sources, but this tends to have a lot of noise.
author Kim Alvefur <zash@zash.se>
date Tue, 09 Mar 2021 14:36:46 +0100
child 11459:86904555bffc
comparison
equal deleted inserted replaced
11431:4874b54af344 11432:113f3912c7cb
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 : number
39 end
40
41 local record error
42 type : error_type
43 condition : error_condition
44 text : string
45 code : number
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