{-# LANGUAGE LambdaCase #-}
module Cardano.CLI.Type.Error.PlutusScriptDecodeError
( PlutusScriptDecodeError (..)
)
where
import Cardano.Api
import Data.Text (Text)
data PlutusScriptDecodeError
= PlutusScriptDecodeErrorUnknownVersion !Text
| PlutusScriptJsonDecodeError !JsonDecodeError
| PlutusScriptDecodeTextEnvelopeError !TextEnvelopeError
| PlutusScriptDecodeErrorVersionMismatch
!Text
!AnyPlutusScriptVersion
deriving Int -> PlutusScriptDecodeError -> ShowS
[PlutusScriptDecodeError] -> ShowS
PlutusScriptDecodeError -> String
(Int -> PlutusScriptDecodeError -> ShowS)
-> (PlutusScriptDecodeError -> String)
-> ([PlutusScriptDecodeError] -> ShowS)
-> Show PlutusScriptDecodeError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PlutusScriptDecodeError -> ShowS
showsPrec :: Int -> PlutusScriptDecodeError -> ShowS
$cshow :: PlutusScriptDecodeError -> String
show :: PlutusScriptDecodeError -> String
$cshowList :: [PlutusScriptDecodeError] -> ShowS
showList :: [PlutusScriptDecodeError] -> ShowS
Show
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