Skip to content

Commit

Permalink
revert change of lookup error message
Browse files Browse the repository at this point in the history
  • Loading branch information
remyhaemmerle-da committed Jul 19, 2021
1 parent b840aa2 commit 8769ee0
Showing 1 changed file with 35 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import com.daml.lf.data.Ref
import com.daml.lf.data.Ref._

final case class LookupError(notFound: Reference, context: Reference) {
val pretty: String = "cannot find " + notFound.pretty + (
val pretty: String = "unknown " + notFound.pretty + (
if (context == notFound) "" else " while looking for " + context.pretty
)
}
Expand All @@ -22,81 +22,78 @@ object LookupError {
}
}

sealed abstract class Reference(description: String) extends Product with Serializable {
def prettyShort: String
final def pretty: String = description + " " + prettyShort
sealed abstract class Reference extends Product with Serializable {
def pretty: String
}

object Reference {

final case class Package(packageId: PackageId) extends Reference("package") {
override def prettyShort: String = packageId
final case class Package(packageId: PackageId) extends Reference {
override def pretty: String = s"unknown package $packageId."
}

final case class Module(packageId: PackageId, moduleName: ModuleName)
extends Reference("module") {
override def prettyShort: String = packageId + " " + moduleName.toString
final case class Module(packageId: PackageId, moduleName: ModuleName) extends Reference {
override def pretty: String = s"unknown module $packageId:$moduleName"
}

final case class Definition(identifier: Ref.Identifier) extends Reference("definition") {
override def prettyShort: String = identifier.toString
final case class Definition(identifier: Ref.Identifier) extends Reference {
override def pretty: String = s"unknown definition $identifier"
}

final case class TypeSyn(tyCon: TypeConName) extends Reference("type synonym") {
override def prettyShort: String = tyCon.toString
final case class TypeSyn(tyCon: TypeConName) extends Reference {
override def pretty: String = s"unknown type synonym $tyCon"
}

final case class DataType(tyCon: TypeConName) extends Reference("user data type") {
override def prettyShort: String = tyCon.toString
final case class DataType(tyCon: TypeConName) extends Reference {
override def pretty: String = s"unknown data type $tyCon"
}

final case class DataRecord(tyCon: TypeConName) extends Reference("record") {
override def prettyShort: String = tyCon.toString
final case class DataRecord(tyCon: TypeConName) extends Reference {
override def pretty: String = s"unknown record $tyCon"
}

final case class DataRecordField(tyCon: TypeConName, fieldName: Ast.VariantConName)
extends Reference("record field") {
override def prettyShort: String = tyCon.toString + ":" + fieldName
final case class DataRecordField(tyCon: TypeConName, fieldName: Ast.FieldName) extends Reference {
override def pretty: String = s"unknown record field $fieldName in record $tyCon"
}

final case class DataVariant(tyCon: TypeConName) extends Reference("variant") {
override def prettyShort: String = tyCon.toString
final case class DataVariant(tyCon: TypeConName) extends Reference {
override def pretty: String = s"unknown variant $tyCon"
}

final case class DataVariantConstructor(
tyCon: TypeConName,
constructorName: Ast.VariantConName,
) extends Reference("variant constructor") {
override def prettyShort: String = tyCon.toString + ":" + constructorName
) extends Reference {
override def pretty: String = s"unknown constructor $constructorName in variant $tyCon"
}

final case class DataEnum(tyCon: TypeConName) extends Reference("enumeration") {
override def prettyShort: String = tyCon.toString
final case class DataEnum(tyCon: TypeConName) extends Reference {
override def pretty: String = s"unknown enumeration $tyCon"
}

final case class DataEnumConstructor(tyCon: TypeConName, constructorName: Ast.EnumConName)
extends Reference("enumeration constructor") {
override def prettyShort: String = tyCon.toString + ":" + constructorName
extends Reference {
override def pretty: String = s"unknown constructor $constructorName in enumeration $tyCon"
}

final case class Value(identifier: Ref.Identifier) extends Reference("value") {
override def prettyShort: String = identifier.toString
final case class Value(identifier: Ref.Identifier) extends Reference {
override def pretty: String = s"unknown value $identifier"
}

final case class Template(tyCon: TypeConName) extends Reference("template") {
override def prettyShort: String = tyCon.toString
final case class Template(tyCon: TypeConName) extends Reference {
override def pretty: String = s"unknown template $tyCon"
}

final case class TemplateKey(tyCon: TypeConName) extends Reference("key for template") {
override def prettyShort: String = tyCon.toString
final case class TemplateKey(tyCon: TypeConName) extends Reference {
override def pretty: String = s"template without contract key $tyCon."
}

final case class Choice(tyCon: TypeConName, choiceName: ChoiceName) extends Reference("choice") {
override def prettyShort: String = tyCon.toString + ":" + choiceName
final case class Choice(tyCon: TypeConName, choiceName: ChoiceName) extends Reference {
override def pretty: String = s"unknown choice $choiceName in template $tyCon"
}

final case class Exception(tyCon: TypeConName) extends Reference("exception") {
override def prettyShort: String = tyCon.toString
final case class Exception(tyCon: TypeConName) extends Reference {
override def pretty: String = s"unknown exception: $tyCon"
}

}

0 comments on commit 8769ee0

Please sign in to comment.