Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include dependency edge info in transition errors #19251

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,26 @@ public void acceptTransitionedConfigurations(

@Override
public void acceptTransitionError(TransitionException e) {
sink.acceptDependencyError(DependencyError.of(e));
sink.acceptDependencyError(
DependencyError.of(new TransitionException(getMessageWithEdgeTransitionInfo(e), e)));
}

@Override
public void acceptTransitionError(OptionsParsingException e) {
sink.acceptDependencyError(DependencyError.of(e));
sink.acceptDependencyError(
DependencyError.of(
new OptionsParsingException(
getMessageWithEdgeTransitionInfo(e), e.getInvalidArgument(), e)));
}

private String getMessageWithEdgeTransitionInfo(Throwable e) {
return String.format(
"On dependency edge %s (%s) -|%s|-> %s: %s",
parameters.target().getLabel(),
parameters.configurationKey().getOptions().shortId(),
kind.getAttribute().getName(),
toLabel,
e.getMessage());
}

private StateMachine processTransitionResult(Tasks tasks) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,20 +87,16 @@ public void addRequiredFragments(
// TODO(blaze-configurability): add more information to this exception e.g. originating target of
// transition.
public static class TransitionException extends Exception {
private final String message;

public TransitionException(String message) {
this.message = message;
super(message);
}

public TransitionException(Throwable cause) {
this.message = cause.getMessage();
super(cause);
}

/** Returns the error message. */
@Override
public String getMessage() {
return message;
public TransitionException(String message, Throwable cause) {
super(message, cause);
}
}

Expand Down
Loading