From: Holger Weiss Date: Mon, 16 Nov 2015 23:12:20 +0000 (+0100) Subject: mod_http_upload: Return error atoms, not strings X-Git-Tag: 16.01~109 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=43626f5c97b1926afedfe6f5822dd1662b87e7f6;p=ejabberd mod_http_upload: Return error atoms, not strings 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. --- diff --git a/src/mod_http_upload.erl b/src/mod_http_upload.erl index d32c5f097..877077906 100644 --- a/src/mod_http_upload.erl +++ b/src/mod_http_upload.erl @@ -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.