Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
PlutusCore.Evaluation.Error
Description
The exceptions that an abstract machine can throw.
Synopsis
- data EvaluationError operational structural
- = OperationalEvaluationError !operational
- | StructuralEvaluationError !structural
- class AsEvaluationError r operational structural | r → operational structural where
- _EvaluationError ∷ Prism' r (EvaluationError operational structural)
- _OperationalEvaluationError ∷ Prism' r operational
- _StructuralEvaluationError ∷ Prism' r structural
Documentation
data EvaluationError operational structural Source #
The type of errors that can occur during evaluation. There are two kinds of errors:
- Operational ones -- these are errors that are indicative of the _logic_ of the program being
wrong. For example,
error
was executed,tailList
was applied to an empty list or evaluation ran out of gas. - Structural ones -- these are errors that are indicative of the _structure_ of the program being
wrong. For example, a free variable was encountered during evaluation, a non-function was
applied to an argument or
tailList
was applied to a non-list.
On the chain both of these are just regular failures and we don't distinguish between them there: if a script fails, it fails, it doesn't matter what the reason was. However in the tests it does matter why the failure occurred: a structural error may indicate that the test was written incorrectly while an operational error may be entirely expected.
In other words, operational errors are regular runtime errors and structural errors are "runtime type errors". Which means that evaluating an (erased) well-typed program should never produce a structural error, only an operational one. This creates a sort of "runtime type system" for UPLC and it would be great to stick to it and enforce in tests etc, but we currently don't. For example, a built-in function expecting a list but getting something else should throw a structural error, but currently it'll throw an operational one. This is something that we plan to improve upon in future.
Constructors
OperationalEvaluationError !operational | |
StructuralEvaluationError !structural |
Instances
class AsEvaluationError r operational structural | r → operational structural where Source #
Minimal complete definition
Methods
_EvaluationError ∷ Prism' r (EvaluationError operational structural) Source #
_OperationalEvaluationError ∷ Prism' r operational Source #
_StructuralEvaluationError ∷ Prism' r structural Source #
Instances
AsEvaluationError UnliftingEvaluationError UnliftingError UnliftingError Source # | |
Defined in PlutusCore.Builtin.Result | |
AsEvaluationError (EvaluationError operational structural) operational structural Source # | |
Defined in PlutusCore.Evaluation.Error Methods _EvaluationError ∷ Prism' (EvaluationError operational structural) (EvaluationError operational structural) Source # _OperationalEvaluationError ∷ Prism' (EvaluationError operational structural) operational Source # _StructuralEvaluationError ∷ Prism' (EvaluationError operational structural) structural Source # |