diff options
author | Peter Andersson <[email protected]> | 2011-09-01 16:32:36 +0200 |
---|---|---|
committer | Peter Andersson <[email protected]> | 2011-09-23 12:24:54 +0200 |
commit | 6668a91b365b8390d8eb369f7d6c6294711a1fef (patch) | |
tree | aeeb629d8dd9c8a3e0b01ae17f32580e782e64d6 /lib/common_test/src/ct_config_plain.erl | |
parent | 8d9b760e7fafec40787be6de5994240f1540d12a (diff) | |
download | otp-6668a91b365b8390d8eb369f7d6c6294711a1fef.tar.gz otp-6668a91b365b8390d8eb369f7d6c6294711a1fef.tar.bz2 otp-6668a91b365b8390d8eb369f7d6c6294711a1fef.zip |
Various corrections and updates to improve error handling and reporting
OTP-8933
Diffstat (limited to 'lib/common_test/src/ct_config_plain.erl')
-rw-r--r-- | lib/common_test/src/ct_config_plain.erl | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/lib/common_test/src/ct_config_plain.erl b/lib/common_test/src/ct_config_plain.erl index 3fbc8af9fb..6698332379 100644 --- a/lib/common_test/src/ct_config_plain.erl +++ b/lib/common_test/src/ct_config_plain.erl @@ -29,7 +29,7 @@ read_config(ConfigFile) -> {ok,Config} -> {ok, Config}; {error,enoent} -> - {error, config_file_error, enoent}; + {error,{config_file_error,file:format_error(enoent)}}; {error,Reason} -> Key = case application:get_env(common_test, decrypt) of @@ -45,23 +45,27 @@ read_config(ConfigFile) -> end, case Key of {error,no_crypt_file} -> - {error, config_file_error, Reason}; + {error,{config_file_error, + lists:flatten( + io_lib:format("~s",[file:format_error(Reason)]))}}; {error,CryptError} -> - {error, decrypt_file_error, CryptError}; + {error,{decrypt_file_error,CryptError}}; _ when is_list(Key) -> - case ct_config:decrypt_config_file(ConfigFile, undefined, {key,Key}) of + case ct_config:decrypt_config_file(ConfigFile, + undefined, + {key,Key}) of {ok,CfgBin} -> case read_config_terms(CfgBin) of {error,ReadFail} -> - {error, config_file_error, ReadFail}; + {error,{config_file_error,ReadFail}}; Config -> - {ok, Config} + {ok,Config} end; {error,DecryptFail} -> - {error, decrypt_config_error, DecryptFail} + {error,{decrypt_config_error,DecryptFail}} end; _ -> - {error, bad_decrypt_key, Key} + {error,{bad_decrypt_key,Key}} end end. @@ -69,9 +73,9 @@ read_config(ConfigFile) -> check_parameter(File)-> case filelib:is_file(File) of true-> - {ok, {file, File}}; + {ok,{file,File}}; false-> - {error, {nofile, File}} + {error,{nofile,File}} end. read_config_terms(Bin) when is_binary(Bin) -> |