-
Notifications
You must be signed in to change notification settings - Fork 231
Various refactors in preparation for adding error reporting #1779
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
Conversation
This allows the solver to just throw an error on failure, rather than wrapping it in an object to eventually get rethrown.
@@ -0,0 +1,47 @@ | |||
// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
year += 1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
lib/src/solver/failure.dart
Outdated
MissingFeatureException(String package, this.version, this.feature, | ||
Iterable<Dependency> dependencies) | ||
: super(package, dependencies); | ||
String toString() => "Tough luck, Chuck!"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a TODO to put something real here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
} else { | ||
return "${terms.first.package.toTerseString()} is incompatible with " | ||
"the current SDK"; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be useful to show the SDK version number here, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a TODO.
|
||
String toString() { | ||
if (cause == IncompatibilityCause.dependency) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think of moving most of this logic into IncompatibilityCause? Something like:
class Incompability {
String toString() => cause.describe(terms);
}
abstract class IncompatibilityCause {
String describe(List<Term> terms);
}
class SdkCause implements IncompatibilityCause {
String describe(List<Term> terms) {
// ...
}
}
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It always weirds me out a bit to have a method like Incompatibility.describe()
that's only ever supposed to be invoked by one specific caller... it feels like kind of the wrong separation of concerns.
f8eeafc
to
38f8976
Compare
This will help us explain version lock to users
Previously, we stopped conflict resolution as soon as we knew that no solution could be found. Now we keep deriving new incompatibilities until we reach one that says the root package can't be selected. This allows us to provide a clearer line of reasoning about why version solving failed to the end user.
The root package is now displayed without a version number or constraint, and PackageRef now properly omits the source name for hosted packages and not for other sources instead of vice versa.
This ensures that constraints constructed by the version solver (rather than authored by humans) that look like ^ constraints are displayed tersely.
Unlike the previous SolveFailure architecture, which had separate subclasses for each type of failure, this includes a single IncompatibilityCause that transitively describes the full reason that the root package couldn't be selected successfully.
Non-derived incompatibilities now indicate their causes, and terms with any constraints no longer list their constraints explicitly.
38f8976
to
3cde899
Compare
Sending these out on their own to avoid dumping another giant pull
request.
See #912