diff --git a/build.sbt b/build.sbt index 85c59512d6..98fcbaa14e 100644 --- a/build.sbt +++ b/build.sbt @@ -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, diff --git a/core/js/src/main/scala/sigma/crypto/Platform.scala b/core/js/src/main/scala/sigma/crypto/Platform.scala index 88001ba140..8424ba935b 100644 --- a/core/js/src/main/scala/sigma/crypto/Platform.scala +++ b/core/js/src/main/scala/sigma/crypto/Platform.scala @@ -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 diff --git a/core/js/src/main/scala/sigma/reflection/Platform.scala b/core/js/src/main/scala/sigma/reflection/Platform.scala index 199729fc7a..8a33c32d06 100644 --- a/core/js/src/main/scala/sigma/reflection/Platform.scala +++ b/core/js/src/main/scala/sigma/reflection/Platform.scala @@ -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)) } diff --git a/core/jvm/src/main/scala/sigma/crypto/Platform.scala b/core/jvm/src/main/scala/sigma/crypto/Platform.scala index b71694e81b..013269f382 100644 --- a/core/jvm/src/main/scala/sigma/crypto/Platform.scala +++ b/core/jvm/src/main/scala/sigma/crypto/Platform.scala @@ -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 diff --git a/core/shared/src/main/scala/sigma/Evaluation.scala b/core/shared/src/main/scala/sigma/Evaluation.scala index d86b7c1650..25d9bc7ff6 100644 --- a/core/shared/src/main/scala/sigma/Evaluation.scala +++ b/core/shared/src/main/scala/sigma/Evaluation.scala @@ -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, @@ -82,7 +83,8 @@ 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. */ @@ -90,7 +92,9 @@ object Evaluation { 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. */ diff --git a/core/shared/src/main/scala/sigma/ast/SType.scala b/core/shared/src/main/scala/sigma/ast/SType.scala index f75cbc9e8b..c9a43d859d 100644 --- a/core/shared/src/main/scala/sigma/ast/SType.scala +++ b/core/shared/src/main/scala/sigma/ast/SType.scala @@ -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", " ")) } @@ -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. */ @@ -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", " ")) } } diff --git a/core/shared/src/main/scala/sigma/data/CSigmaProp.scala b/core/shared/src/main/scala/sigma/data/CSigmaProp.scala index d8a472424c..924fd75b24 100644 --- a/core/shared/src/main/scala/sigma/data/CSigmaProp.scala +++ b/core/shared/src/main/scala/sigma/data/CSigmaProp.scala @@ -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] = { diff --git a/core/shared/src/main/scala/sigma/serialization/CoreDataSerializer.scala b/core/shared/src/main/scala/sigma/serialization/CoreDataSerializer.scala index b4b20feb4c..39760fcd25 100644 --- a/core/shared/src/main/scala/sigma/serialization/CoreDataSerializer.scala +++ b/core/shared/src/main/scala/sigma/serialization/CoreDataSerializer.scala @@ -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) diff --git a/core/shared/src/main/scala/sigma/serialization/TypeSerializer.scala b/core/shared/src/main/scala/sigma/serialization/TypeSerializer.scala index 9c84de0944..ac460feefd 100644 --- a/core/shared/src/main/scala/sigma/serialization/TypeSerializer.scala +++ b/core/shared/src/main/scala/sigma/serialization/TypeSerializer.scala @@ -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 diff --git a/data/shared/src/main/scala/org/ergoplatform/ErgoBoxCandidate.scala b/data/shared/src/main/scala/org/ergoplatform/ErgoBoxCandidate.scala index ba306159d4..d97b119aad 100644 --- a/data/shared/src/main/scala/org/ergoplatform/ErgoBoxCandidate.scala +++ b/data/shared/src/main/scala/org/ergoplatform/ErgoBoxCandidate.scala @@ -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) @@ -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 @@ -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", " ")) } } } diff --git a/data/shared/src/main/scala/sigma/ast/syntax.scala b/data/shared/src/main/scala/sigma/ast/syntax.scala index 5a257481cb..dff7fecbf5 100644 --- a/data/shared/src/main/scala/sigma/ast/syntax.scala +++ b/data/shared/src/main/scala/sigma/ast/syntax.scala @@ -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. diff --git a/sc/shared/src/test/scala/sigma/SigmaDslTesting.scala b/sc/shared/src/test/scala/sigma/SigmaDslTesting.scala index 31e873699b..45a8283472 100644 --- a/sc/shared/src/test/scala/sigma/SigmaDslTesting.scala +++ b/sc/shared/src/test/scala/sigma/SigmaDslTesting.scala @@ -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