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 50 first error messages #1018

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
3 changes: 2 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ lazy val commonSettings = Seq(
Seq("-Ywarn-unused:_,imports", "-Ywarn-unused:imports", "-release", "8")
case Some((2, 11)) =>
Seq()
case _ => sys.error("Unsupported scala version")
case _ => sys.error("""The Scala version you are using is not supported. Please use a supported version of Scala.
|For more details, visit our Scala version compatibility guide.""".stripMargin.replaceAll("\n", " "))
}
},
javacOptions ++= javacReleaseOption,
Expand Down
4 changes: 3 additions & 1 deletion core/js/src/main/scala/sigma/crypto/Platform.scala
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,9 @@ object Platform {
case c: Coll[_] => tpe match {
case STuple(items) => c.tItem == sigma.AnyType && c.length == items.length
case tpeColl: SCollection[_] => true
case _ => sys.error(s"Collection value $c has unexpected type $tpe")
case _ => sys.error(s"""The collection value $c has an unexpected type: $tpe.
|Please ensure the value is of the expected type.
|For more details, refer to our type compatibility guide.""".stripMargin.replaceAll("\n", " "))
}
case _: Option[_] => tpe.isOption
case _: Tuple2[_, _] => tpe.isTuple && tpe.asTuple.items.length == 2
Expand Down
4 changes: 3 additions & 1 deletion core/js/src/main/scala/sigma/reflection/Platform.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ object Platform {
assert(c.clazz == clazz)
c
case _ =>
sys.error(s"Cannot find RClass data for $clazz")
sys.error(s"""We couldn't find the RClass data for $clazz.
|Please verify that the class name is correct and try again.
|For further assistance, visit our RClass data documentation.""".stripMargin.replaceAll("\n", " "))
// Uncomment the following line to collect missing reflection data and generate Scala code for it
// memoize(classes)(clazz, new JRClass[T](clazz))
}
Expand Down
4 changes: 3 additions & 1 deletion core/jvm/src/main/scala/sigma/crypto/Platform.scala
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,9 @@ object Platform {
case c: Coll[_] => tpe match {
case STuple(items) => c.tItem == sigma.AnyType && c.length == items.length
case _: SCollection[_] => true
case _ => sys.error(s"Collection value $c has unexpected type $tpe")
case _ => sys.error(s"""The collection value $c has an unexpected type: $tpe.
|Please ensure the value is of the expected type.
|For more details, refer to our type compatibility guide.""".stripMargin.replaceAll("\n", " "))
}
case _: Option[_] => tpe.isOption
case _: Tuple2[_, _] => tpe.isTuple && tpe.asTuple.items.length == 2
Expand Down
10 changes: 7 additions & 3 deletions core/shared/src/main/scala/sigma/Evaluation.scala
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ object Evaluation {
val tpeArg = args(0)
funcRType(stypeToRType(tpeArg), stypeToRType(tpeRange))
case _ =>
sys.error(s"Don't know how to convert SType $t to RType")
sys.error(s"""We couldn't convert SType $t to RType. Please ensure that $t is compatible with RType.
|For detailed guidance, visit our type conversion documentation.""".stripMargin.replaceAll("\n", " "))
}).asInstanceOf[RType[T#WrappedType]]

/** Transforms RType descriptor of SigmaDsl, which is used during evaluation,
Expand Down Expand Up @@ -82,15 +83,18 @@ object Evaluation {
case ct: CollType[_] => SCollection(rtypeToSType(ct.tItem))
case ft: FuncType[_,_] => SFunc(rtypeToSType(ft.tDom), rtypeToSType(ft.tRange))
case pt: PairType[_,_] => STuple(rtypeToSType(pt.tFst), rtypeToSType(pt.tSnd))
case _ => sys.error(s"Don't know how to convert RType $t to SType")
case _ => sys.error(s"""We couldn't convert SType $t to RType. Please ensure that $t is compatible with RType.
|For detailed guidance, visit our type conversion documentation.""".stripMargin.replaceAll("\n", " "))
}

/** Convert SigmaDsl representation of tuple to ErgoTree serializable representation. */
def fromDslTuple(value: Any, tupleTpe: STuple): Coll[Any] = value match {
case t: Tuple2[_,_] => TupleColl(t._1, t._2)
case a: Coll[Any]@unchecked if a.tItem == sigma.AnyType => a
case _ =>
sys.error(s"Cannot execute fromDslTuple($value, $tupleTpe)")
sys.error(s"""Execution failed for fromDslTuple with value $value and type $tupleTpe.
|Please ensure the value matches the expected tuple type.
|For more details, refer to our DSL tuple documentation.""".stripMargin.replaceAll("\n", " "))
}

/** Convert ErgoTree serializable representation of tuple to SigmaDsl representation. */
Expand Down
22 changes: 16 additions & 6 deletions core/shared/src/main/scala/sigma/ast/SType.scala
Original file line number Diff line number Diff line change
Expand Up @@ -163,17 +163,21 @@ object SType {
case _: SOption[_] => x.isInstanceOf[Option[_]]
case t: STuple =>
if (t.items.length == 2) x.isInstanceOf[Tuple2[_,_]]
else sys.error(s"Unsupported tuple type $t")
else sys.error(s"""The tuple type $t is not supported.
|Please ensure you are using a compatible tuple type.
|For further assistance, consult our tuple type documentation.""".stripMargin.replaceAll("\n", " "))
case tF: SFunc =>
if (tF.tDom.length == 1) x.isInstanceOf[Function1[_,_]]
else sys.error(s"Unsupported function type $tF")
else sys.error(s"""The function type $tF is not supported. Please ensure you are using a compatible function type.
|For more details, refer to our function type documentation.""".stripMargin.replaceAll("\n", " "))
case SContext => x.isInstanceOf[Context]
case SAvlTree => x.isInstanceOf[AvlTree]
case SGlobal => x.isInstanceOf[SigmaDslBuilder]
case SHeader => x.isInstanceOf[Header]
case SPreHeader => x.isInstanceOf[PreHeader]
case SUnit => x.isInstanceOf[Unit]
case _ => sys.error(s"Unknown type $tpe")
case _ => sys.error(s"""The type $tpe is unknown. Please verify the type and ensure it is correctly defined.
|For further assistance, consult our type definition documentation.""".stripMargin.replaceAll("\n", " "))
}


Expand Down Expand Up @@ -346,7 +350,9 @@ object SNumericType extends STypeCompanion {
override def typeId: TypeCode = 106: Byte

/** Since this object is not used in SMethod instances. */
override def reprClass: RClass[_] = sys.error(s"Shouldn't be called.")
override def reprClass: RClass[_] = sys.error("""The reprClass method should not be invoked.
|Please review the documentation for correct usage.
|For more information, refer to our reprClass documentation.""".stripMargin.replaceAll("\n", " "))
}

/** Descriptor of ErgoTree type `Boolean` holding `true` or `false` values. */
Expand All @@ -368,14 +374,18 @@ case object SByte extends SPrimType with SEmbeddable with SNumericType with SMon
override def numericTypeIndex: Int = 0
override def upcast(v: AnyVal): Byte = v match {
case b: Byte => b
case _ => sys.error(s"Cannot upcast value $v to the type $this")
case _ => sys.error(s"""Unable to upcast value $v to type $this.
|Please ensure compatibility between the value and the expected type.
|For more guidance, refer to our type casting documentation.""".stripMargin.replaceAll("\n", " "))
}
override def downcast(v: AnyVal): Byte = v match {
case b: Byte => b
case s: Short => s.toByteExact
case i: Int => i.toByteExact
case l: Long => l.toByteExact
case _ => sys.error(s"Cannot downcast value $v to the type $this")
case _ => sys.error(s"""Unable to downcast value $v to type $this.
|Please ensure compatibility between the value and the expected type.
|For more guidance, refer to our type casting documentation.""".stripMargin.replaceAll("\n", " "))
}
}

Expand Down
4 changes: 3 additions & 1 deletion core/shared/src/main/scala/sigma/data/CSigmaProp.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ case class CSigmaProp(sigmaTree: SigmaBoolean) extends SigmaProp with WrapperOf[
// TODO refactor: remove this (it shouldn't be used in interpreter)
override def isValid: Boolean = sigmaTree match {
case p: TrivialProp => p.condition
case _ => sys.error(s"Method CostingSigmaProp.isValid is not defined for $sigmaTree")
case _ => sys.error(s"""The method CostingSigmaProp.isValid is not defined for the $sigmaTree.
|Please ensure you are using the correct method for $sigmaTree.
|For further details, refer to our CostingSigmaProp documentation.""".stripMargin.replaceAll("\n", " "))
}

override def propBytes: Coll[Byte] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ class CoreDataSerializer {
val len = arr.length
assert(arr.length == t.items.length, s"Type $t doesn't correspond to value $arr")
if (len > 0xFFFF)
sys.error(s"Length of tuple ${arr.length} exceeds ${0xFFFF} limit.")
sys.error(s"""The tuple length (${arr.length}) exceeds the maximum limit (${0xFFFF}).
|Please reduce the tuple size to meet the limit.
|For more details, refer to our tuple length documentation.""".stripMargin.replaceAll("\n", " "))
var i = 0
while (i < arr.length) {
serialize[SType](arr(i), t.items(i), w)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ class TypeSerializer {
serialize(t2, w)
}
case STuple(items) if items.length < 2 =>
sys.error(s"Invalid Tuple type with less than 2 items $items")
sys.error(
s"""The Tuple type with less than 2 items ($items) is invalid.
|Please ensure tuples have at least 2 items for proper functionality.
|For guidance, refer to our Tuple type documentation.""".stripMargin.replaceAll("\n", " "))
case tup: STuple => tup.items.length match {
case 3 =>
// Triple of types
Expand Down
15 changes: 11 additions & 4 deletions data/shared/src/main/scala/org/ergoplatform/ErgoBoxCandidate.scala
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,9 @@ object ErgoBoxCandidate {
val amount = amounts(i)
if (tokensInTx.isDefined) {
val tokenIndex = tokensInTx.get.indexWhere(_ == id, 0) // using equality on Coll
if (tokenIndex == -1) sys.error(s"failed to find token id ($id) in tx's digest index")
if (tokenIndex == -1) sys.error(s"""Failed to locate token ID ($id) in the transaction's digest index.
|Please verify the token ID and try again.
|For further assistance, consult our transaction documentation.""".stripMargin.replaceAll("\n", " "))
w.putUInt(tokenIndex)
} else {
w.putBytes(id.toArray)
Expand All @@ -161,7 +163,10 @@ object ErgoBoxCandidate {

val nRegs = box.additionalRegisters.keys.size
if (nRegs + ErgoBox.startingNonMandatoryIndex > 255)
sys.error(s"The number of non-mandatory indexes $nRegs exceeds ${255 - ErgoBox.startingNonMandatoryIndex} limit.")
sys.error(
s"""The number of non-mandatory indexes ($nRegs) exceeds the maximum limit (${255 - ErgoBox.startingNonMandatoryIndex}).
|Please reduce the number of non-mandatory indexes to meet the limit.
|For more details, refer to our indexing documentation.""".stripMargin.replaceAll("\n", " "))
w.putUByte(nRegs)
// we assume non-mandatory indexes are densely packed from startingNonMandatoryIndex
// this convention allows to save 1 bite for each register
Expand All @@ -173,8 +178,10 @@ object ErgoBoxCandidate {
case Some(v) =>
w.putValue(v)
case None =>
sys.error(s"Set of non-mandatory indexes is not densely packed: " +
s"register R$regId is missing in the range [$startReg .. $endReg]")
sys.error(s"""The set of non-mandatory indexes is not densely packed:
|register R$regId is missing in the range [$startReg .. $endReg].
|Please ensure all registers in this range are sequentially filled.
|For more information, refer to our register packing guidelines.""".stripMargin.replaceAll("\n", " "))
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion data/shared/src/main/scala/sigma/ast/syntax.scala
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ object syntax {
def length: Int = matchCase(_.items.length, _.value.length, _.items.length)

/** Returns a sequence of items in the collection expression. */
def items: Seq[Value[SType]] = matchCase(_.items, _ => sys.error(s"Cannot get 'items' property of node $coll"), _.items)
def items: Seq[Value[SType]] = matchCase(_.items, _ => sys.error(
s"""Unable to retrieve the 'items' property of node $coll.
|Please ensure the node is correctly initialized and has the items property available.
|For further assistance, refer to our node documentation.""".stripMargin.replaceAll("\n", " ")), _.items)

/** Abstracts from details of pattern matching collection expressions.
* Folds over given `coll` structure.
Expand Down
4 changes: 3 additions & 1 deletion sc/shared/src/test/scala/sigma/SigmaDslTesting.scala
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,9 @@ class SigmaDslTesting extends AnyPropSpec
)(implicit IR: IRContext, override val evalSettings: EvalSettings, val tA: RType[A], val tB: RType[B])
extends Feature[A, B] {
override def scalaFunc: A => B = { x =>
sys.error(s"Semantic Scala function is not defined for old implementation: $this")
sys.error(s"The Semantic Scala function is not defined for the current implementation: $this.
|Please update your implementation to the latest version.
|For more information, visit our Scala function documentation.".stripMargin.replaceAll("\n", " "))
}
implicit val cs = compilerSettingsInTests

Expand Down
Loading