mirror of
https://github.com/bjc/prosody.git
synced 2025-04-01 20:27:39 +03:00
util.error: Use is_error() instead of is_err() everywhere
Continuation of 4b39691a274e
This commit is contained in:
parent
ff05b0773d
commit
73b512d3a6
3 changed files with 9 additions and 9 deletions
|
@ -206,7 +206,7 @@ local function handle_result(request, response, result)
|
|||
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
|
||||
|
|
|
@ -153,7 +153,7 @@ local function bounce_sendq(session, reason)
|
|||
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;
|
||||
|
|
|
@ -29,10 +29,10 @@ describe("util.error", function ()
|
|||
|
||||
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 @@ describe("util.error", function ()
|
|||
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 @@ describe("util.error", function ()
|
|||
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 @@ describe("util.error", function ()
|
|||
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 @@ describe("util.error", function ()
|
|||
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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue