{-# LANGUAGE LambdaCase #-}
module Cardano.CLI.Types.Errors.PlutusScriptDecodeError
( PlutusScriptDecodeError (..)
)
where
import Cardano.Api
import Data.Text (Text)
data PlutusScriptDecodeError
= PlutusScriptDecodeErrorUnknownVersion !Text
| PlutusScriptJsonDecodeError !JsonDecodeError
| PlutusScriptDecodeTextEnvelopeError !TextEnvelopeError
| PlutusScriptDecodeErrorVersionMismatch
!Text
!AnyPlutusScriptVersion
instance Error PlutusScriptDecodeError where
prettyError :: forall ann. PlutusScriptDecodeError -> Doc ann
prettyError = \case
PlutusScriptDecodeErrorUnknownVersion Text
version ->
Doc ann
"Unknown Plutus script version: " Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Text -> Doc ann
forall a ann. Pretty a => a -> Doc ann
forall ann. Text -> Doc ann
pretty Text
version
PlutusScriptJsonDecodeError JsonDecodeError
err ->
JsonDecodeError -> Doc ann
forall e ann. Error e => e -> Doc ann
forall ann. JsonDecodeError -> Doc ann
prettyError JsonDecodeError
err
PlutusScriptDecodeTextEnvelopeError TextEnvelopeError
err ->
TextEnvelopeError -> Doc ann
forall e ann. Error e => e -> Doc ann
forall ann. TextEnvelopeError -> Doc ann
prettyError TextEnvelopeError
err
PlutusScriptDecodeErrorVersionMismatch Text
version (AnyPlutusScriptVersion PlutusScriptVersion lang
v) ->
Doc ann
"Version mismatch in code: script version that was read"
Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Text -> Doc ann
forall a ann. Pretty a => a -> Doc ann
forall ann. Text -> Doc ann
pretty Text
version
Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Doc ann
" but tried to decode script version: "
Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PlutusScriptVersion lang -> Doc ann
forall a ann. Show a => a -> Doc ann
pshow PlutusScriptVersion lang
v