couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fdman...@apache.org
Subject svn commit: r1056694 - /couchdb/trunk/src/couchdb/couch_config.erl
Date Sat, 08 Jan 2011 11:57:42 GMT
Author: fdmanana
Date: Sat Jan  8 11:57:42 2011
New Revision: 1056694

URL: http://svn.apache.org/viewvc?rev=1056694&view=rev
Log:
Add missing case for COUCHDB-966

When not able to read one of the .ini configuration files due to file permissions,
map {error, eacces} into {file_permission_error, Filepath} and throw that as an exception.

Modified:
    couchdb/trunk/src/couchdb/couch_config.erl

Modified: couchdb/trunk/src/couchdb/couch_config.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_config.erl?rev=1056694&r1=1056693&r2=1056694&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_config.erl (original)
+++ couchdb/trunk/src/couchdb/couch_config.erl Sat Jan  8 11:57:42 2011
@@ -93,15 +93,19 @@ register(Fun, Pid) ->
 
 init(IniFiles) ->
     ets:new(?MODULE, [named_table, set, protected]),
-    lists:map(fun(IniFile) ->
-        {ok, ParsedIniValues} = parse_ini_file(IniFile),
-        ets:insert(?MODULE, ParsedIniValues)
-    end, IniFiles),
-    WriteFile = case IniFiles of
-        [_|_] -> lists:last(IniFiles);
-        _ -> undefined
-    end,
-    {ok, #config{write_filename=WriteFile}}.
+    try
+        lists:map(fun(IniFile) ->
+            {ok, ParsedIniValues} = parse_ini_file(IniFile),
+            ets:insert(?MODULE, ParsedIniValues)
+        end, IniFiles),
+        WriteFile = case IniFiles of
+            [_|_] -> lists:last(IniFiles);
+            _ -> undefined
+        end,
+        {ok, #config{write_filename = WriteFile}}
+    catch _Tag:Error ->
+        {stop, Error}
+    end.
 
 
 terminate(_Reason, _State) ->
@@ -183,6 +187,8 @@ parse_ini_file(IniFile) ->
     case file:read_file(IniFilename) of
         {ok, IniBin0} ->
             IniBin0;
+        {error, eacces} ->
+            throw({file_permission_error, IniFile});
         {error, enoent} ->
             Fmt = "Couldn't find server configuration file ~s.",
             Msg = ?l2b(io_lib:format(Fmt, [IniFilename])),



Mime
View raw message