summaryrefslogtreecommitdiff
path: root/src/rebar_file_utils.erl
diff options
context:
space:
mode:
authorFred Hebert <mononcqc@ferd.ca>2015-05-22 14:34:46 -0400
committerFred Hebert <mononcqc@ferd.ca>2015-05-22 14:34:46 -0400
commit5f577e2ab15d0aa3b6650f4e3d1ee086be3dc736 (patch)
treee7ae0873e879bf92ac9f9c51926f34781cab9d16 /src/rebar_file_utils.erl
parentb7acb56f4710fe3fd11163f6874f82f0008625b6 (diff)
parent476a80c33ee0d835e58eae3b3bb396eae401b9ec (diff)
Merge pull request #470 from tsloughter/master
print and format error message for bad .app files and all bad configs
Diffstat (limited to 'src/rebar_file_utils.erl')
-rw-r--r--src/rebar_file_utils.erl18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/rebar_file_utils.erl b/src/rebar_file_utils.erl
index ef2c70f..ad30172 100644
--- a/src/rebar_file_utils.erl
+++ b/src/rebar_file_utils.erl
@@ -26,7 +26,9 @@
%% -------------------------------------------------------------------
-module(rebar_file_utils).
--export([symlink_or_copy/2,
+-export([try_consult/1,
+ format_error/1,
+ symlink_or_copy/2,
rm_rf/1,
cp_r/2,
mv/2,
@@ -37,11 +39,25 @@
reset_dir/1]).
-include("rebar.hrl").
+-include_lib("providers/include/providers.hrl").
%% ===================================================================
%% Public API
%% ===================================================================
+try_consult(File) ->
+ case file:consult(File) of
+ {ok, Terms} ->
+ Terms;
+ {error, enoent} ->
+ [];
+ {error, Reason} ->
+ throw(?PRV_ERROR({bad_term_file, File, Reason}))
+ end.
+
+format_error({bad_term_file, AppFile, Reason}) ->
+ io_lib:format("Error reading file ~s: ~s", [AppFile, file:format_error(Reason)]).
+
symlink_or_copy(Source, Target) ->
Link = case os:type() of
{win32, _} ->