aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2016-06-29 10:07:46 +0200
committerBjörn Gustavsson <[email protected]>2016-06-29 10:07:46 +0200
commitb67da3610ace6d4e998bdfb458343165e205fae8 (patch)
tree79221bb04ce84c640d76de6fcf0e50753e5b00e9
parentd6adc4785391c7970ead778d27f33dd8c5b51380 (diff)
parent10ea3707cb220d1b936ce103e78d2a500e6c03e6 (diff)
downloadotp-b67da3610ace6d4e998bdfb458343165e205fae8.tar.gz
otp-b67da3610ace6d4e998bdfb458343165e205fae8.tar.bz2
otp-b67da3610ace6d4e998bdfb458343165e205fae8.zip
Merge branch 'legoscia/compiler/error-handling/PR-1112/OTP-13701' into maint
* legoscia/compiler/error-handling/PR-1112/OTP-13701: Fix try-catch when writing makefile Show error reason when compiler cannot write file
-rw-r--r--lib/compiler/src/compile.erl12
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/compiler/src/compile.erl b/lib/compiler/src/compile.erl
index 82ff8a95f3..e2eff2a89b 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)]);
@@ -1206,7 +1208,7 @@ makedep_output(#compile{code=Code,options=Opts,ofile=Ofile}=St) ->
end,
{ok,St}
catch
- exit:_ ->
+ error:_ ->
%% Couldn't write to output Makefile.
Err = {St#compile.ifile,[{none,?MODULE,write_error}]},
{error,St#compile{errors=St#compile.errors++[Err]}}
@@ -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.