Fail loudly on error when executing a cmd in an app.src vsn#2543
Fail loudly on error when executing a cmd in an app.src vsn#2543aronisstav wants to merge 2 commits intoerlang:mainfrom
Conversation
ferd
left a comment
There was a problem hiding this comment.
Can you show the expected difference between the old output and the new one? I'm having a bit of a hard time just tracing in my mind what the difference in output is expected to look like.
|
|
||
| cmd_vsn_invoke(Cmd, Dir) -> | ||
| {ok, VsnString} = rebar_utils:sh(Cmd, [{cd, Dir}, {use_stdout, false}]), | ||
| ErrorOpt = {abort_on_error, "vsn cmd in .app.src failed"}, |
There was a problem hiding this comment.
if the error message takes place this deep, then it would make sense not to make assumptions on what the caller was doing ("was it really called in a .app.src file?") and simply report the error at its own level (something like "Command x failed") to prevent misguiding error messages when the callsites are expanded.
If we want to provide contextual errors with high-level concerns, then we would need to put in a conditional here and return {ok, VsnString} | {error, Term} and move the reporting to the parent.
There was a problem hiding this comment.
Can you clarify a little bit? I am guessing you mean that this code could be reached in different ways, but my understanding, without really checking, is that the only way to reach cmd_vsn_invoke/2 is when really evaluating a cmd in a vsn property, in an .app.src file, which is what my error message reports.
There was a problem hiding this comment.
Yeah this is more of future-proofing. I.e. the function cmd_vsn_invoke knows it is about a version, but has no idea it actually comes from a .app.src file.
Right, I forgot! Before: After: |
|
|
||
| cmd_vsn_invoke(Cmd, Dir) -> | ||
| {ok, VsnString} = rebar_utils:sh(Cmd, [{cd, Dir}, {use_stdout, false}]), | ||
| ErrorOpt = {abort_on_error, "vsn cmd in .app.src failed"}, |
There was a problem hiding this comment.
It would be good to add the actual filename or path here as well. Otherwise, if you have many apps its up to the user to find the one with the bad vsn command
This PR fixes a bug.
Description
When running
rebar3 compileon a strange environment (Windows...), acmdcommand in avsnattribute in an.app.srcfile failed.Expected behaviour
An error is prominently displayed.
Actual behaviour
The error was only available with
DEBUG=1and localizing it to thevsnattribute took quite some further digging.Additional info
While at it, make it so that
{abort_on_error, Msg}ALSO shows the error that generated it, indiscriminately. This is a little breaking, but should be a good thing.I think that this PR is good enough as-is. I might have time to also add a test, if someone kindly points out specifically where.