]> granicus.if.org Git - ejabberd/commitdiff
mod_http_upload: Return error atoms, not strings
authorHolger Weiss <holger@zedat.fu-berlin.de>
Mon, 16 Nov 2015 23:12:20 +0000 (00:12 +0100)
committerHolger Weiss <holger@zedat.fu-berlin.de>
Mon, 16 Nov 2015 23:12:20 +0000 (00:12 +0100)
Don't convert error atoms to strings before actually logging them.  This
avoids a bogus error message when a user who has no uploaded files is
removed.

src/mod_http_upload.erl

index d32c5f097bcc5f0430fa1a4f2c7275e7d6e4fec2..87707790685fa1db647fef210bb10f300e072d40 100644 (file)
@@ -409,7 +409,7 @@ process([_UserDir, _RandDir, _FileName] = Slot,
                    http_response(Host, 201, Headers, OutData);
                {error, Error} ->
                    ?ERROR_MSG("Cannot store file ~s from ~s for ~s: ~p",
-                              [Path, ?ADDR_TO_STR(IP), Host, Error]),
+                              [Path, ?ADDR_TO_STR(IP), Host, ?FORMAT(Error)]),
                    http_response(Host, 500)
            end;
        {ok, Size, Path} ->
@@ -830,7 +830,7 @@ do_store_file(Path, Data, FileMode, DirMode) ->
        ok = Ok % Raise an exception if file:write/2 failed.
     catch
        _:{badmatch, {error, Error}} ->
-           {error, ?FORMAT(Error)};
+           {error, Error};
        _:Error ->
            {error, Error}
     end.
@@ -977,7 +977,7 @@ remove_user(User, Server) ->
            ?DEBUG("Found no HTTP upload directory of ~s@~s", [User, Server]);
        {error, Error} ->
            ?ERROR_MSG("Cannot remove HTTP upload directory of ~s@~s: ~p",
-                      [User, Server, Error])
+                      [User, Server, ?FORMAT(Error)])
     end,
     ok.
 
@@ -999,7 +999,7 @@ del_tree(Dir) ->
        ok = file:del_dir(Dir)
     catch
        _:{badmatch, {error, Error}} ->
-           {error, ?FORMAT(Error)};
+           {error, Error};
        _:Error ->
            {error, Error}
     end.