Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
PlutusCore.Evaluation.Machine.Exception
Description
The exceptions that an abstract machine can throw.
Synopsis
- newtype UnliftingError = MkUnliftingError {}
- data BuiltinError
- data MachineError fun
- = NonPolymorphicInstantiationMachineError
- | NonWrapUnwrappedMachineError
- | NonFunctionalApplicationMachineError
- | OpenTermEvaluatedMachineError
- | UnliftingMachineError UnliftingError
- | BuiltinTermArgumentExpectedMachineError
- | UnexpectedBuiltinTermArgumentMachineError
- | NonConstrScrutinizedMachineError
- | MissingCaseBranchMachineError Word64
- | PanicMachineError String
- data EvaluationError structural operational
- = StructuralError !structural
- | OperationalError !operational
- data ErrorWithCause err cause = ErrorWithCause {}
- type EvaluationException structural operational = ErrorWithCause (EvaluationError structural operational)
- notAConstant ∷ BuiltinError
- throwErrorWithCause ∷ MonadError (ErrorWithCause e cause) m ⇒ e → cause → m x
- splitStructuralOperational ∷ Either (EvaluationException structural operational term) a → Either (ErrorWithCause structural term) (EvaluationResult a)
- unsafeSplitStructuralOperational ∷ (PrettyPlc structural, PrettyPlc term, Typeable structural, Typeable term) ⇒ Either (EvaluationException structural operational term) a → EvaluationResult a
- class BuiltinErrorToEvaluationError structural operational
- builtinErrorToEvaluationError ∷ BuiltinErrorToEvaluationError structural operational ⇒ BuiltinError → EvaluationError structural operational
- throwBuiltinErrorWithCause ∷ (MonadError (EvaluationException structural operational cause) m, BuiltinErrorToEvaluationError structural operational) ⇒ cause → BuiltinError → m void
Documentation
newtype UnliftingError Source #
The error message part of an UnliftingEvaluationError
.
Constructors
MkUnliftingError | |
Fields |
Instances
IsString UnliftingError Source # | |
Defined in PlutusCore.Builtin.Result Methods | |
Monoid UnliftingError Source # | |
Defined in PlutusCore.Builtin.Result Methods mempty ∷ UnliftingError Source # mappend ∷ UnliftingError → UnliftingError → UnliftingError Source # | |
Semigroup UnliftingError Source # | |
Defined in PlutusCore.Builtin.Result Methods (<>) ∷ UnliftingError → UnliftingError → UnliftingError Source # sconcat ∷ NonEmpty UnliftingError → UnliftingError Source # stimes ∷ Integral b ⇒ b → UnliftingError → UnliftingError Source # | |
Show UnliftingError Source # | |
Defined in PlutusCore.Builtin.Result | |
NFData UnliftingError Source # | |
Defined in PlutusCore.Builtin.Result Methods rnf ∷ UnliftingError → () Source # | |
Eq UnliftingError Source # | |
Defined in PlutusCore.Builtin.Result Methods (==) ∷ UnliftingError → UnliftingError → Bool Source # (/=) ∷ UnliftingError → UnliftingError → Bool Source # | |
Pretty UnliftingError Source # | |
Defined in PlutusCore.Builtin.Result |
data BuiltinError Source #
The type of errors that readKnown
and makeKnown
can return.
Instances
Show BuiltinError Source # | |
Defined in PlutusCore.Builtin.Result | |
Eq BuiltinError Source # | |
Defined in PlutusCore.Builtin.Result Methods (==) ∷ BuiltinError → BuiltinError → Bool Source # (/=) ∷ BuiltinError → BuiltinError → Bool Source # | |
Pretty BuiltinError Source # | |
Defined in PlutusCore.Builtin.Result | |
MonadError BuiltinError BuiltinResult Source # |
|
Defined in PlutusCore.Builtin.Result Methods throwError ∷ BuiltinError → BuiltinResult a Source # catchError ∷ BuiltinResult a → (BuiltinError → BuiltinResult a) → BuiltinResult a Source # |
data MachineError fun Source #
Errors which can occur during a run of an abstract machine.
Constructors
NonPolymorphicInstantiationMachineError | An attempt to reduce a not immediately reducible type instantiation. |
NonWrapUnwrappedMachineError | An attempt to unwrap a not wrapped term. |
NonFunctionalApplicationMachineError | An attempt to reduce a not immediately reducible application. |
OpenTermEvaluatedMachineError | An attempt to evaluate an open term. |
UnliftingMachineError UnliftingError | An attempt to compute a constant application resulted in |
BuiltinTermArgumentExpectedMachineError | A builtin expected a term argument, but something else was received. |
UnexpectedBuiltinTermArgumentMachineError | A builtin received a term argument when something else was expected |
NonConstrScrutinizedMachineError | An attempt to scrutinize a non-constr. |
MissingCaseBranchMachineError Word64 | An attempt to go into a non-existent case branch. |
PanicMachineError String | A GHC exception was thrown. |
Instances
data EvaluationError structural operational Source #
The type of errors that can occur during evaluation. There are two kinds of errors:
- 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. - 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.
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, structural errors are "runtime type errors" and operational errors are regular runtime 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.
Constructors
StructuralError !structural | |
OperationalError !operational |
Instances
data ErrorWithCause err cause Source #
An error and (optionally) what caused it.
Constructors
ErrorWithCause | |
Instances
type EvaluationException structural operational = ErrorWithCause (EvaluationError structural operational) Source #
throwErrorWithCause ∷ MonadError (ErrorWithCause e cause) m ⇒ e → cause → m x Source #
splitStructuralOperational ∷ Either (EvaluationException structural operational term) a → Either (ErrorWithCause structural term) (EvaluationResult a) Source #
Preserve the contents of an StructuralError
as a Left
and turn an
OperationalError
into a Right EvaluationFailure
(thus erasing the content of the
error in the latter case).
unsafeSplitStructuralOperational ∷ (PrettyPlc structural, PrettyPlc term, Typeable structural, Typeable term) ⇒ Either (EvaluationException structural operational term) a → EvaluationResult a Source #
Throw on a StructuralError
and turn an OperationalError
into an
EvaluationFailure
(thus erasing the content of the error in the latter case).
class BuiltinErrorToEvaluationError structural operational Source #
Minimal complete definition
Instances
builtinErrorToEvaluationError ∷ BuiltinErrorToEvaluationError structural operational ⇒ BuiltinError → EvaluationError structural operational Source #
throwBuiltinErrorWithCause ∷ (MonadError (EvaluationException structural operational cause) m, BuiltinErrorToEvaluationError structural operational) ⇒ cause → BuiltinError → m void Source #
Attach a cause
to a BuiltinError
and throw that.
Note that an evaluator might require the cause to be computed lazily for best performance on the
happy path, hence this function must not force its first argument.
TODO: wrap cause
in Lazy
once we have it.