aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler
diff options
context:
space:
mode:
authorMagnus Henoch <[email protected]>2016-06-22 13:45:18 +0100
committerMagnus Henoch <[email protected]>2016-06-22 13:45:18 +0100
commitfe954ec3f29cfff9f421ae967b47fc9aac24c248 (patch)
treecdbb8608da4b2bea59449a7daef85b0b0e96bd21 /lib/compiler
parent3b7a6ffddc819bf305353a593904cea9e932e7dc (diff)
downloadotp-fe954ec3f29cfff9f421ae967b47fc9aac24c248.tar.gz
otp-fe954ec3f29cfff9f421ae967b47fc9aac24c248.tar.bz2
otp-fe954ec3f29cfff9f421ae967b47fc9aac24c248.zip
Show error reason when compiler cannot write file
When the compiler fails to write an output file, it used to just print "error writing file". With this change, it also prints the error reason: $ echo "-module(foo)." > foo.erl $ chmod -w . $ erlc foo.erl /tmp/bar/foo.bea#: error writing file: permission denied
Diffstat (limited to 'lib/compiler')
-rw-r--r--lib/compiler/src/compile.erl10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/compiler/src/compile.erl b/lib/compiler/src/compile.erl
index 82ff8a95f3..9fdfdadebf 100644
--- a/lib/compiler/src/compile.erl
+++ b/lib/compiler/src/compile.erl
@@ -236,6 +236,8 @@ format_error({epp,E}) ->
epp:format_error(E);
format_error(write_error) ->
"error writing file";
+format_error({write_error, Error}) ->
+ io_lib:format("error writing file: ~ts", [file:format_error(Error)]);
format_error({rename,From,To,Error}) ->
io_lib:format("failed to rename ~ts to ~ts: ~ts",
[From,To,file:format_error(Error)]);
@@ -1479,8 +1481,8 @@ save_binary_1(St) ->
end,
{error,St#compile{errors=St#compile.errors ++ Es}}
end;
- {error,_Error} ->
- Es = [{Tfile,[{none,compile,write_error}]}],
+ {error,Error} ->
+ Es = [{Tfile,[{none,compile,{write_error,Error}}]}],
{error,St#compile{errors=St#compile.errors ++ Es}}
end.
@@ -1628,8 +1630,8 @@ listing(LFun, Ext, St) ->
LFun(Lf, Code),
ok = file:close(Lf),
{ok,St};
- {error,_Error} ->
- Es = [{Lfile,[{none,compile,write_error}]}],
+ {error,Error} ->
+ Es = [{Lfile,[{none,compile,{write_error,Error}}]}],
{error,St#compile{errors=St#compile.errors ++ Es}}
end.