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

Update MissingPackage error to allow reporting by package name #19972

Merged
merged 1 commit into from
Sep 27, 2024

Conversation

raphael-speyer-da
Copy link
Collaborator

@raphael-speyer-da raphael-speyer-da commented Sep 19, 2024

In the participant, the handling of a command which contains a template id whose package id is not known should be the same, irrespective of whether the template id specified the package with a package id or a package name. From that point of view, it makes sense to handle both cases with the same error.

If the MissingPackage type contained a PackageRef rather than a PackageId it could make this more uniform, and cases which did need to distinguish could still pattern match on the subtype of PackageRef, as needed.

@@ -86,7 +86,7 @@ final class ValueEnricher(

private[this] def handleLookup[X](lookup: => Either[LookupError, X]) = lookup match {
case Right(value) => ResultDone(value)
case Left(LookupError.MissingPackage(pkgId, context)) =>
case Left(LookupError.MissingPackage(PackageRef.Id(pkgId), context)) =>
Copy link
Collaborator Author

@raphael-speyer-da raphael-speyer-da Sep 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Case where we need different handling for missing package by id vs name, and can distinguish easily enough.

Comment on lines -50 to -51
final case class PackageWithName(packageName: PackageName) extends Reference {
override def pretty: String = s"package $packageName"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaced with Package(PackageRef.Name(...))

def apply(packageRef: Ref.PackageRef): MissingPackage =
MissingPackage(packageRef, language.Reference.Package(packageRef))

def apply(packageId: Ref.PackageId): MissingPackage = apply(Ref.PackageRef.Id(packageId))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep overloads for building with a PackageId for convenience and compatibility.

Copy link
Collaborator

@remyhaemmerle-da remyhaemmerle-da left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable.
Thanks.

@raphael-speyer-da raphael-speyer-da merged commit d5dda36 into main Sep 27, 2024
15 checks passed
@raphael-speyer-da raphael-speyer-da deleted the rls/errors-with-package-ref-a branch September 27, 2024 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants