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 15:34:34 UTC
[couchdb] 01/01: Fix maybe_handle_error clauses
This is an automated email from the ASF dual-hosted git repository.
vatamane pushed a commit to branch fix-clause-order
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 78f42c56090318fe1ff106acca052434c0a441de
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..36df02db4 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)}
+ Error1 ->
+ {500, <<"unknown_error">>, couch_util:to_binary(Error1)}
end.
error_headers(#httpd{mochi_req = MochiReq} = Req, 401 = Code, ErrorStr, ReasonStr) ->