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:33 UTC

[couchdb] branch fix-clause-order created (now 78f42c560)

This is an automated email from the ASF dual-hosted git repository.

vatamane pushed a change to branch fix-clause-order
in repository https://gitbox.apache.org/repos/asf/couchdb.git


      at 78f42c560 Fix maybe_handle_error clauses

This branch includes the following new commits:

     new 78f42c560 Fix maybe_handle_error clauses

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[couchdb] 01/01: Fix maybe_handle_error clauses

Posted by va...@apache.org.
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) ->