You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by va...@apache.org on 2022/05/11 16:27:50 UTC
[couchdb] branch 3.x updated: Fix maybe_handle_error clauses
This is an automated email from the ASF dual-hosted git repository.
vatamane pushed a commit to branch 3.x
in repository https://gitbox.apache.org/repos/asf/couchdb.git
The following commit(s) were added to refs/heads/3.x by this push:
new 8b44f476f Fix maybe_handle_error clauses
8b44f476f is described below
commit 8b44f476fddc866826e294dee3ee0687f19877bb
Author: Nick Vatamaniuc <va...@gmail.com>
AuthorDate: Wed May 11 11:28:49 2022 -0400
Fix maybe_handle_error clauses
`{shutdown, Err}` should come before `{Err Reason}`, otherwise {Err, Reason} will always match.
Also, plugin `handle_error/1` response was forced to match initial `Error`,
which doesn't have to always be the case based on:
https://github.com/apache/couchdb/blob/42f2c1c534ed5c210b45ffcd9a621a31b781b5ae/src/chttpd/src/chttpd_plugin.erl#L39-L41
---
src/chttpd/src/chttpd.erl | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/chttpd/src/chttpd.erl b/src/chttpd/src/chttpd.erl
index cd8982aa1..4f6ec06c7 100644
--- a/src/chttpd/src/chttpd.erl
+++ b/src/chttpd/src/chttpd.erl
@@ -1134,14 +1134,14 @@ maybe_handle_error(Error) ->
case chttpd_plugin:handle_error(Error) of
{_Code, _Reason, _Description} = Result ->
Result;
+ {shutdown, Err} ->
+ exit({shutdown, Err});
{Err, Reason} ->
{500, couch_util:to_binary(Err), couch_util:to_binary(Reason)};
normal ->
exit(normal);
- {shutdown, Err} ->
- exit({shutdown, Err});
- Error ->
- {500, <<"unknown_error">>, couch_util:to_binary(Error)}
+ Err ->
+ {500, <<"unknown_error">>, couch_util:to_binary(Err)}
end.
error_headers(#httpd{mochi_req = MochiReq} = Req, 401 = Code, ErrorStr, ReasonStr) ->