Skip to content

Commit e0cc6e5

Browse files
authored
Merge pull request #1063 from jozanek/drop-sigma-exception-args
Drop unused args argument from SigmaException.
2 parents db4db60 + ac38d23 commit e0cc6e5

File tree

10 files changed

+35
-42
lines changed

10 files changed

+35
-42
lines changed
Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
package sigma
22

3-
import scala.collection.compat.immutable.ArraySeq
4-
53
/** Base class for Sigma-related exceptions.
64
*
75
* @param message the error message
86
* @param cause an optional cause for the exception
97
* @param args an optional sequence of arguments to be passed with the exception
108
*/
119
class SigmaException(
12-
val message: String,
13-
val cause: Option[Throwable] = None,
14-
val args: Seq[Any] = ArraySeq.empty) extends Exception(message, cause.orNull)
15-
16-
17-
10+
val message: String,
11+
val cause: Option[Throwable] = None
12+
) extends Exception(message, cause.orNull)

core/shared/src/main/scala/sigma/serialization/CoreSerializer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import java.nio.ByteBuffer
99
/** Implementation of [[Serializer]] provided by `sigma-core` module. */
1010
abstract class CoreSerializer[TFamily, T <: TFamily] extends Serializer[TFamily, T, CoreByteReader, CoreByteWriter] {
1111

12-
def error(msg: String) = throw SerializerException(msg, None)
12+
def error(msg: String) = throw SerializerException(msg)
1313

1414
/** Serializes the given 'obj' to a new array of bytes using this serializer. */
1515
final def toBytes(obj: T): Array[Byte] = {

core/shared/src/main/scala/sigma/serialization/SerializerException.scala

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,33 @@ package sigma.serialization
22

33
import sigma.SigmaException
44

5-
import scala.collection.compat.immutable.ArraySeq
6-
75
/** Exception thrown during serialization.
86
*
97
* @param message the error message
108
* @param cause an optional cause for the exception
119
*/
1210
case class SerializerException(
1311
override val message: String,
14-
override val cause: Option[Throwable] = None,
15-
override val args: Seq[Any] = ArraySeq.empty
16-
)
17-
extends SigmaException(message, cause, args)
12+
override val cause: Option[Throwable] = None
13+
) extends SigmaException(message, cause)
1814

1915
/** Thrown by TypeSerializer when type prefix <= 0. */
20-
final class InvalidTypePrefix(message: String, cause: Option[Throwable] = None)
21-
extends SerializerException(message, cause)
16+
final class InvalidTypePrefix(message: String)
17+
extends SerializerException(message)
2218

2319
/** Thrown when the current reader position > positionLimit which is set in the Reader.
2420
* @see [[org.ergoplatform.validation.ValidationRules.CheckPositionLimit]]
2521
*/
2622
final class ReaderPositionLimitExceeded(
2723
message: String,
2824
val position: Int,
29-
val positionLimit: Int,
30-
cause: Option[Throwable] = None)
31-
extends SerializerException(message, cause)
25+
val positionLimit: Int
26+
) extends SerializerException(message)
3227

3328
/** Thrown when the current depth level > maxDepthLevel which is set in the Reader. */
34-
final class DeserializeCallDepthExceeded(message: String, cause: Option[Throwable] = None)
35-
extends SerializerException(message, cause)
29+
final class DeserializeCallDepthExceeded(message: String)
30+
extends SerializerException(message)
3631

3732
/** Thrown by [[org.ergoplatform.validation.ValidationRules.CheckValidOpCode]] validation rule. */
38-
final class InvalidOpCode(message: String, cause: Option[Throwable] = None)
39-
extends SerializerException(message, cause)
33+
final class InvalidOpCode(message: String)
34+
extends SerializerException(message)

data/shared/src/main/scala/sigma/exceptions/CompilerExceptions.scala

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ import sigma.ast.SourceContext
77
*
88
* @param message the error message
99
* @param source an optional source context with location information
10-
* @param cause an optional cause for the exception
1110
*/
12-
class CompilerException(message: String, val source: Option[SourceContext] = None, cause: Option[Throwable] = None)
13-
extends SigmaException(message, cause) {
11+
class CompilerException(message: String, val source: Option[SourceContext] = None)
12+
extends SigmaException(message, None) {
1413

1514
override def getMessage: String = source.map { srcCtx =>
1615
val lineNumberStrPrefix = s"line ${srcCtx.line}: "
@@ -43,8 +42,8 @@ class TyperException(message: String, source: Option[SourceContext] = None)
4342
class BuilderException(message: String, source: Option[SourceContext] = None)
4443
extends CompilerException(message, source)
4544

46-
class GraphBuildingException(message: String, source: Option[SourceContext], cause: Option[Throwable] = None)
47-
extends CompilerException(message, source, cause)
45+
class GraphBuildingException(message: String, source: Option[SourceContext])
46+
extends CompilerException(message, source)
4847

4948

5049

data/shared/src/main/scala/sigma/exceptions/SigmaExceptions.scala

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@ class InterpreterException(message: String, cause: Option[Throwable] = None)
1818
* @param cause an optional cause for the exception
1919
*/
2020
class CostLimitException(
21-
val estimatedCost: Long,
22-
message: String,
23-
cause: Option[Throwable] = None)
24-
extends SigmaException(message, cause)
21+
val estimatedCost: Long,
22+
message: String
23+
) extends SigmaException(message, None)
2524

2625
object CostLimitException {
2726
/** Generates a cost limit error message.

data/shared/src/main/scala/sigma/serialization/SigmaSerializer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ object SigmaSerializer {
6565

6666
abstract class SigmaSerializer[TFamily, T <: TFamily] extends Serializer[TFamily, T, SigmaByteReader, SigmaByteWriter] {
6767

68-
def error(msg: String) = throw new SerializerException(msg, None)
68+
def error(msg: String) = throw new SerializerException(msg)
6969

7070
final def toBytes(obj: T): Array[Byte] = {
7171
val w = SigmaSerializer.startWriter()

interpreter/shared/src/main/scala/sigmastate/eval/package.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ package object eval {
4747
message = {
4848
val suffix = if (msgSuffix.isEmpty) "" else s": $msgSuffix"
4949
msgCostLimitError(newCost, limit) + suffix
50-
},
51-
cause = None)
50+
}
51+
)
5252
}
5353
newCost
5454
}

interpreter/shared/src/main/scala/sigmastate/interpreter/CostAccumulator.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ class CostAccumulator(initialCost: JitCost, costLimit: Option[JitCost]) {
6262
val accumulatedCost = currentScope.currentCost
6363
if (accumulatedCost > limit) {
6464
throw new CostLimitException(
65-
accumulatedCost.value, CostLimitException.msgCostLimitError(accumulatedCost, limit), None)
65+
accumulatedCost.value,
66+
CostLimitException.msgCostLimitError(accumulatedCost, limit)
67+
)
6668
}
6769
}
6870
}

sc/shared/src/test/scala/sigmastate/serialization/DeserializationResilience.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,10 @@ class DeserializationResilience extends DeserializationResilienceTesting {
136136
assertExceptionThrown(
137137
ErgoBoxCandidate.serializer.parse(SigmaSerializer.startReader(w.toBytes)),
138138
{
139-
case SerializerException(_,
140-
Some(ValidationException(_,CheckPositionLimit,_,
141-
Some(_: ReaderPositionLimitExceeded))), _) => true
139+
case SerializerException(
140+
_,
141+
Some(ValidationException(_, CheckPositionLimit, _, Some(_: ReaderPositionLimitExceeded)))
142+
) => true
142143
case _ => false
143144
})
144145
case _ =>

sdk/shared/src/main/scala/org/ergoplatform/sdk/ReducingInterpreter.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ class ReducingInterpreter(params: BlockchainParameters) extends ErgoLikeInterpre
3434
val initCost = context.initCost
3535
val remainingLimit = context.costLimit - initCost
3636
if (remainingLimit <= 0)
37-
throw new CostLimitException(initCost,
38-
s"Estimated execution cost $initCost exceeds the limit ${context.costLimit}", None)
37+
throw new CostLimitException(
38+
initCost,
39+
s"Estimated execution cost $initCost exceeds the limit ${context.costLimit}"
40+
)
3941
val ctxUpdInitCost = context.withInitCost(initCost)
4042
val res = fullReduction(ergoTree, ctxUpdInitCost, env)
4143
ReducedInputData(res, ctxUpdInitCost.extension)

0 commit comments

Comments
 (0)