Software /
code /
prosody
Changeset
13534:d532176d4334
util.error: Use is_error() instead of is_err() everywhere
Continuation of 4b39691a274e
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 29 Oct 2024 14:10:02 +0100 |
parents | 13533:c885594f7f9a |
children | 13535:88cab98aa28c |
files | net/http/server.lua plugins/mod_s2s.lua spec/util_error_spec.lua |
diffstat | 3 files changed, 9 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/net/http/server.lua Sun Oct 27 15:23:45 2024 +0100 +++ b/net/http/server.lua Tue Oct 29 14:10:02 2024 +0100 @@ -206,7 +206,7 @@ end elseif result_type == "string" then body = result; - elseif errors.is_err(result) then + elseif errors.is_error(result) then response.status_code = result.code or 500; body = events.fire_event("http-error", { request = request, response = response, code = result.code or 500, error = result }); elseif promise.is_promise(result) then
--- a/plugins/mod_s2s.lua Sun Oct 27 15:23:45 2024 +0100 +++ b/plugins/mod_s2s.lua Tue Oct 29 14:10:02 2024 +0100 @@ -153,7 +153,7 @@ if session.had_stream then -- set when a stream is opened by the remote error_type, condition = "wait", "remote-server-timeout"; end - if errors.is_err(reason) then + if errors.is_error(reason) then error_type, condition, reason_text = reason.type, reason.condition, reason.text; elseif type(reason) == "string" then reason_text = reason;
--- a/spec/util_error_spec.lua Sun Oct 27 15:23:45 2024 +0100 +++ b/spec/util_error_spec.lua Tue Oct 29 14:10:02 2024 +0100 @@ -29,10 +29,10 @@ end); - describe("is_err()", function () + describe("is_error()", function () it("works", function () - assert.truthy(errors.is_err(errors.new())); - assert.falsy(errors.is_err("not an error")); + assert.truthy(errors.is_error(errors.new())); + assert.falsy(errors.is_error("not an error")); end); end); @@ -40,7 +40,7 @@ it("works", function () local ok, err = errors.coerce(nil, "it dun goofed"); assert.is_nil(ok); - assert.truthy(errors.is_err(err)) + assert.truthy(errors.is_error(err)) end); end); @@ -50,7 +50,7 @@ local m = st.message({ type = "chat" }); local e = st.error_reply(m, "modify", "bad-request", nil, "error.example"):tag("extra", { xmlns = "xmpp:example.test" }); local err = errors.from_stanza(e); - assert.truthy(errors.is_err(err)); + assert.truthy(errors.is_error(err)); assert.equal("modify", err.type); assert.equal("bad-request", err.condition); assert.equal(e, err.context.stanza); @@ -187,7 +187,7 @@ end local ok, err = reg.coerce(test()); assert.is_nil(ok); - assert.is_truthy(errors.is_err(err)); + assert.is_truthy(errors.is_error(err)); assert.equal("forbidden", err.condition); end); @@ -208,7 +208,7 @@ end local ok, err = reg.coerce(test()); assert.is_nil(ok); - assert.is_truthy(errors.is_err(err)); + assert.is_truthy(errors.is_error(err)); assert.equal("internal-server-error", err.condition); assert.equal("Oh no", err.text); end);