{-# LANGUAGE LambdaCase #-}
module Cardano.CLI.Types.Errors.DebugCmdError
( DebugCmdError (..)
)
where
import Cardano.Api
import qualified Cardano.Api.Byron as Byron
import Cardano.CLI.Types.Errors.TxCmdError
import Data.Text (Text)
import qualified Data.Text.Lazy.Builder as Text
import Formatting.Buildable (build)
data DebugCmdError
= DebugCmdFailed
|
DebugNodeConfigGenesisDataCmdError !FilePath !Byron.GenesisDataError
|
DebugNodeConfigWrongGenesisHashCmdError
!FilePath
!FilePath
!Text
!Text
|
DebugNodeConfigNoConwayFileCmdError
!FilePath
|
DebugNodeConfigNoConwayHashCmdError
!FilePath
| DebugTxCmdError !TxCmdError
instance Error DebugCmdError where
prettyError :: forall ann. DebugCmdError -> Doc ann
prettyError = \case
DebugCmdError
DebugCmdFailed -> Doc ann
"Debug command failed"
DebugNodeConfigGenesisDataCmdError FilePath
fp GenesisDataError
err ->
Doc ann
"Error reading node configuration at: "
Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> FilePath -> Doc ann
forall ann. FilePath -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty FilePath
fp
Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
": "
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 (Builder -> Text
Text.toLazyText (Builder -> Text) -> Builder -> Text
forall a b. (a -> b) -> a -> b
$ GenesisDataError -> Builder
forall p. Buildable p => p -> Builder
build GenesisDataError
err)
DebugNodeConfigNoConwayFileCmdError FilePath
fp ->
Doc ann
"Conway genesis file not specified in "
Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> FilePath -> Doc ann
forall ann. FilePath -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty FilePath
fp
Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
". Please add a \"ConwayGenesisFile\" key to the file at "
Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> FilePath -> Doc ann
forall ann. FilePath -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty FilePath
fp
DebugNodeConfigNoConwayHashCmdError FilePath
fp ->
Doc ann
"Conway genesis hash not specified in "
Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> FilePath -> Doc ann
forall ann. FilePath -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty FilePath
fp
Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
". Please add a \"ConwayGenesisHash\" key to the file at "
Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> FilePath -> Doc ann
forall ann. FilePath -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty FilePath
fp
DebugNodeConfigWrongGenesisHashCmdError FilePath
nodeFp FilePath
genesisFp Text
actualHash Text
expectedHash ->
Doc ann
"Wrong genesis hash for "
Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> FilePath -> Doc ann
forall ann. FilePath -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty FilePath
genesisFp
Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
" in "
Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> FilePath -> Doc ann
forall ann. FilePath -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty FilePath
nodeFp
Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
": when computing the hash, got: "
Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Text -> Doc ann
forall ann. Text -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty Text
actualHash
Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
", but the node configuration files states that this hash is expected: "
Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Text -> Doc ann
forall ann. Text -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty Text
expectedHash
DebugTxCmdError TxCmdError
err -> TxCmdError -> Doc ann
forall ann. TxCmdError -> Doc ann
renderTxCmdError TxCmdError
err