@@ -7674,18 +7674,53 @@ mod error_mapping {
7674
7674
const SQRTI_ERROR_MESSAGE : & str = "sqrti must be passed a positive integer" ;
7675
7675
const POW_ERROR_MESSAGE : & str = "Power argument to (pow ...) must be a u32 integer" ;
7676
7676
7677
+ /// Represents various error conditions that can occur
7678
+ /// during Clarity contract execution
7679
+ /// or other Stacks blockchain operations.
7680
+ #[ derive( Debug , Clone , Copy , PartialEq , Eq ) ]
7677
7681
pub enum ErrorMap {
7682
+ /// Indicates that the error is not related to Clarity contract execution.
7678
7683
NotClarityError = -1 ,
7684
+
7685
+ /// Represents an arithmetic overflow error in Clarity contract execution.
7686
+ /// This occurs when a calculation exceeds the maximum value representable.
7679
7687
ArithmeticOverflow = 0 ,
7688
+
7689
+ /// Represents an arithmetic underflow error in Clarity contract execution.
7690
+ /// This occurs when a calculation results in a value below the minimum representable value.
7680
7691
ArithmeticUnderflow = 1 ,
7692
+
7693
+ /// Indicates an attempt to divide by zero in a Clarity contract.
7681
7694
DivisionByZero = 2 ,
7695
+
7696
+ /// Represents an error in calculating the logarithm base 2 in a Clarity contract.
7697
+ /// This could occur for negative inputs.
7682
7698
ArithmeticLog2Error = 3 ,
7699
+
7700
+ /// Represents an error in calculating the integer square root in a Clarity contract.
7701
+ /// This could occur for negative inputs.
7683
7702
ArithmeticSqrtiError = 4 ,
7684
- UnwrapFailure = 5 ,
7703
+
7704
+ /// Indicates an error in constructing a type, possibly due to invalid parameters.
7705
+ BadTypeConstruction = 5 ,
7706
+
7707
+ /// Represents a deliberate panic in contract execution,
7708
+ /// usually triggered by `(unwrap-panic...)` and `(unwrap-err-panic...)`.
7685
7709
Panic = 6 ,
7710
+
7711
+ /// Indicates a failure in an assertion that was expected to cause a short return,
7712
+ /// usually triggered by `(asserts!...)`.
7686
7713
ShortReturnAssertionFailure = 7 ,
7714
+
7715
+ /// Represents an error in exponentiation operations in a Clarity contract.
7716
+ /// This could occur for invalid bases or exponents.
7687
7717
ArithmeticPowError = 8 ,
7718
+
7719
+ /// Indicates an attempt to use a name that is already in use, possibly for a variable or function.
7688
7720
NameAlreadyUsed = 9 ,
7721
+
7722
+ /// A catch-all for errors that are not mapped to specific error codes.
7723
+ /// This might be used for unexpected or unclassified errors.
7689
7724
NotMapped = 99 ,
7690
7725
}
7691
7726
@@ -7698,7 +7733,7 @@ mod error_mapping {
7698
7733
2 => ErrorMap :: DivisionByZero ,
7699
7734
3 => ErrorMap :: ArithmeticLog2Error ,
7700
7735
4 => ErrorMap :: ArithmeticSqrtiError ,
7701
- 5 => ErrorMap :: UnwrapFailure ,
7736
+ 5 => ErrorMap :: BadTypeConstruction ,
7702
7737
6 => ErrorMap :: Panic ,
7703
7738
7 => ErrorMap :: ShortReturnAssertionFailure ,
7704
7739
8 => ErrorMap :: ArithmeticPowError ,
@@ -7806,8 +7841,8 @@ mod error_mapping {
7806
7841
RuntimeErrorType :: Arithmetic ( SQRTI_ERROR_MESSAGE . into ( ) ) ,
7807
7842
Some ( Vec :: new ( ) ) ,
7808
7843
) ,
7809
- ErrorMap :: UnwrapFailure => {
7810
- Error :: Runtime ( RuntimeErrorType :: UnwrapFailure , Some ( Vec :: new ( ) ) )
7844
+ ErrorMap :: BadTypeConstruction => {
7845
+ Error :: Runtime ( RuntimeErrorType :: BadTypeConstruction , Some ( Vec :: new ( ) ) )
7811
7846
}
7812
7847
ErrorMap :: Panic => {
7813
7848
// TODO: see issue: #531
0 commit comments