Software /
code /
prosody
Annotate
net/http/errors.lua @ 11523:5f15ab7c6ae5
Statistics: Rewrite statistics backends to use OpenMetrics
The metric subsystem of Prosody has had some shortcomings from
the perspective of the current state-of-the-art in metric
observability.
The OpenMetrics standard [0] is a formalization of the data
model (and serialization format) of the well-known and
widely-used Prometheus [1] software stack.
The previous stats subsystem of Prosody did not map well to that
format (see e.g. [2] and [3]); the key reason is that it was
trying to do too much math on its own ([2]) while lacking
first-class support for "families" of metrics ([3]) and
structured metric metadata (despite the `extra` argument to
metrics, there was no standard way of representing common things
like "tags" or "labels").
Even though OpenMetrics has grown from the Prometheus world of
monitoring, it maps well to other popular monitoring stacks
such as:
- InfluxDB (labels can be mapped to tags and fields as necessary)
- Carbon/Graphite (labels can be attached to the metric name with
dot-separation)
- StatsD (see graphite when assuming that graphite is used as
backend, which is the default)
The util.statsd module has been ported to use the OpenMetrics
model as a proof of concept. An implementation which exposes
the util.statistics backend data as Prometheus metrics is
ready for publishing in prosody-modules (most likely as
mod_openmetrics_prometheus to avoid breaking existing 0.11
deployments).
At the same time, the previous measure()-based API had one major
advantage: It is really simple and easy to use without requiring
lots of knowledge about OpenMetrics or similar concepts. For that
reason as well as compatibility with existing code, it is preserved
and may even be extended in the future.
However, code relying on the `stats-updated` event as well as
`get_stats` from `statsmanager` will break because the data
model has changed completely; in case of `stats-updated`, the
code will simply not run (as the event was renamed in order
to avoid conflicts); the `get_stats` function has been removed
completely (so it will cause a traceback when it is attempted
to be used).
Note that the measure_*_event methods have been removed from
the module API. I was unable to find any uses or documentation
and thus deemed they should not be ported. Re-implementation is
possible when necessary.
[0]: https://openmetrics.io/
[1]: https://prometheus.io/
[2]: #959
[3]: #960
author | Jonas Schäfer <jonas@wielicki.name> |
---|---|
date | Sun, 18 Apr 2021 11:47:41 +0200 |
parent | 11225:8c17c08d100e |
child | 12974:ba409c67353b |
rev | line source |
---|---|
11025
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1 -- This module returns a table that is suitable for use as a util.error registry, |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2 -- and a function to return a util.error object given callback 'code' and 'body' |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3 -- parameters. |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4 |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5 local codes = require "net.http.codes"; |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6 local util_error = require "util.error"; |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7 |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8 local error_templates = { |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9 -- This code is used by us to report a client-side or connection error. |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
10 -- Instead of using the code, use the supplied body text to get one of |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
11 -- the more detailed errors below. |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
12 [0] = { |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
13 code = 0, type = "cancel", condition = "internal-server-error"; |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
14 text = "Connection or internal error"; |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
15 }; |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
16 |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
17 -- These are net.http built-in errors, they are returned in |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
18 -- the body parameter when code == 0 |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
19 ["cancelled"] = { |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
20 code = 0, type = "cancel", condition = "remote-server-timeout"; |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
21 text = "Request cancelled"; |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
22 }; |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
23 ["connection-closed"] = { |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
24 code = 0, type = "wait", condition = "remote-server-timeout"; |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
25 text = "Connection closed"; |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
26 }; |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
27 ["certificate-chain-invalid"] = { |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
28 code = 0, type = "cancel", condition = "remote-server-timeout"; |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
29 text = "Server certificate not trusted"; |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
30 }; |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
31 ["certificate-verify-failed"] = { |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
32 code = 0, type = "cancel", condition = "remote-server-timeout"; |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
33 text = "Server certificate invalid"; |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
34 }; |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
35 ["connection failed"] = { |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
36 code = 0, type = "cancel", condition = "remote-server-not-found"; |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
37 text = "Connection failed"; |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
38 }; |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
39 ["invalid-url"] = { |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
40 code = 0, type = "modify", condition = "bad-request"; |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
41 text = "Invalid URL"; |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
42 }; |
11225
8c17c08d100e
net.http.errors: Add error class for DNS resolution failures (thanks SouL)
Matthew Wild <mwild1@gmail.com>
parents:
11025
diff
changeset
|
43 ["unable to resolve service"] = { |
8c17c08d100e
net.http.errors: Add error class for DNS resolution failures (thanks SouL)
Matthew Wild <mwild1@gmail.com>
parents:
11025
diff
changeset
|
44 code = 0, type = "cancel", condition = "remote-server-not-found"; |
8c17c08d100e
net.http.errors: Add error class for DNS resolution failures (thanks SouL)
Matthew Wild <mwild1@gmail.com>
parents:
11025
diff
changeset
|
45 text = "DNS resolution failed"; |
8c17c08d100e
net.http.errors: Add error class for DNS resolution failures (thanks SouL)
Matthew Wild <mwild1@gmail.com>
parents:
11025
diff
changeset
|
46 }; |
11025
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
47 |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
48 -- This doesn't attempt to map every single HTTP code (not all have sane mappings), |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
49 -- but all the common ones should be covered. XEP-0086 was used as reference for |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
50 -- most of these. |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
51 [400] = { type = "modify", condition = "bad-request" }; |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
52 [401] = { type = "auth", condition = "not-authorized" }; |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
53 [402] = { type = "auth", condition = "payment-required" }; |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
54 [403] = { type = "auth", condition = "forbidden" }; |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
55 [404] = { type = "cancel", condition = "item-not-found" }; |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
56 [405] = { type = "cancel", condition = "not-allowed" }; |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
57 [406] = { type = "modify", condition = "not-acceptable" }; |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
58 [407] = { type = "auth", condition = "registration-required" }; |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
59 [408] = { type = "wait", condition = "remote-server-timeout" }; |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
60 [409] = { type = "cancel", condition = "conflict" }; |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
61 [410] = { type = "cancel", condition = "gone" }; |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
62 [411] = { type = "modify", condition = "bad-request" }; |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
63 [412] = { type = "cancel", condition = "conflict" }; |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
64 [413] = { type = "modify", condition = "resource-constraint" }; |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
65 [414] = { type = "modify", condition = "resource-constraint" }; |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
66 [415] = { type = "cancel", condition = "feature-not-implemented" }; |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
67 [416] = { type = "modify", condition = "bad-request" }; |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
68 |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
69 [422] = { type = "modify", condition = "bad-request" }; |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
70 [423] = { type = "wait", condition = "resource-constraint" }; |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
71 |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
72 [429] = { type = "wait", condition = "resource-constraint" }; |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
73 [431] = { type = "modify", condition = "resource-constraint" }; |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
74 [451] = { type = "auth", condition = "forbidden" }; |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
75 |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
76 [500] = { type = "wait", condition = "internal-server-error" }; |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
77 [501] = { type = "cancel", condition = "feature-not-implemented" }; |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
78 [502] = { type = "wait", condition = "remote-server-timeout" }; |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
79 [503] = { type = "cancel", condition = "service-unavailable" }; |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
80 [504] = { type = "wait", condition = "remote-server-timeout" }; |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
81 [507] = { type = "wait", condition = "resource-constraint" }; |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
82 [511] = { type = "auth", condition = "not-authorized" }; |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
83 }; |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
84 |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
85 for k, v in pairs(codes) do |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
86 if error_templates[k] then |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
87 error_templates[k].code = k; |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
88 error_templates[k].text = v; |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
89 else |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
90 error_templates[k] = { type = "cancel", condition = "undefined-condition", text = v, code = k }; |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
91 end |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
92 end |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
93 |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
94 setmetatable(error_templates, { |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
95 __index = function(_, k) |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
96 if type(k) ~= "number" then |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
97 return nil; |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
98 end |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
99 return { |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
100 type = "cancel"; |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
101 condition = "undefined-condition"; |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
102 text = codes[k] or (k.." Unassigned"); |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
103 code = k; |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
104 }; |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
105 end |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
106 }); |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
107 |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
108 local function new(code, body, context) |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
109 if code == 0 then |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
110 return util_error.new(body, context, error_templates); |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
111 else |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
112 return util_error.new(code, context, error_templates); |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
113 end |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
114 end |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
115 |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
116 return { |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
117 registry = error_templates; |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
118 new = new; |
e47e7185b403
net.http.errors: Add new module for converting net.http errors to util.error objects
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
119 }; |