{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Cardano.CLI.Types.Errors.KeyCmdError
( KeyCmdError (..)
, renderKeyCmdError
)
where
import Cardano.Api
import qualified Cardano.CLI.Byron.Key as Byron
import Cardano.CLI.Types.Errors.CardanoAddressSigningKeyConversionError
import Cardano.CLI.Types.Errors.ItnKeyConversionError
import Cardano.CLI.Types.Key
import Data.Text (Text)
data KeyCmdError
= KeyCmdReadFileError !(FileError TextEnvelopeError)
| KeyCmdReadKeyFileError !(FileError InputDecodeError)
| KeyCmdWriteFileError !(FileError ())
| KeyCmdByronKeyFailure !Byron.ByronKeyFailure
|
KeyCmdByronKeyParseError
!Text
| KeyCmdItnKeyConvError !ItnKeyConversionError
| KeyCmdWrongKeyTypeError
| KeyCmdCardanoAddressSigningKeyFileError
!(FileError CardanoAddressSigningKeyConversionError)
| KeyCmdNonLegacyKey !FilePath
| KeyCmdExpectedExtendedVerificationKey SomeAddressVerificationKey
| KeyCmdVerificationKeyReadError VerificationKeyTextOrFileError
deriving Int -> KeyCmdError -> ShowS
[KeyCmdError] -> ShowS
KeyCmdError -> String
(Int -> KeyCmdError -> ShowS)
-> (KeyCmdError -> String)
-> ([KeyCmdError] -> ShowS)
-> Show KeyCmdError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> KeyCmdError -> ShowS
showsPrec :: Int -> KeyCmdError -> ShowS
$cshow :: KeyCmdError -> String
show :: KeyCmdError -> String
$cshowList :: [KeyCmdError] -> ShowS
showList :: [KeyCmdError] -> ShowS
Show
renderKeyCmdError :: KeyCmdError -> Doc ann
renderKeyCmdError :: forall ann. KeyCmdError -> Doc ann
renderKeyCmdError KeyCmdError
err =
case KeyCmdError
err of
KeyCmdReadFileError FileError TextEnvelopeError
fileErr ->
FileError TextEnvelopeError -> Doc ann
forall e ann. Error e => e -> Doc ann
forall ann. FileError TextEnvelopeError -> Doc ann
prettyError FileError TextEnvelopeError
fileErr
KeyCmdReadKeyFileError FileError InputDecodeError
fileErr ->
FileError InputDecodeError -> Doc ann
forall e ann. Error e => e -> Doc ann
forall ann. FileError InputDecodeError -> Doc ann
prettyError FileError InputDecodeError
fileErr
KeyCmdWriteFileError FileError ()
fileErr ->
FileError () -> Doc ann
forall e ann. Error e => e -> Doc ann
forall ann. FileError () -> Doc ann
prettyError FileError ()
fileErr
KeyCmdByronKeyFailure ByronKeyFailure
e ->
ByronKeyFailure -> Doc ann
forall ann. ByronKeyFailure -> Doc ann
Byron.renderByronKeyFailure ByronKeyFailure
e
KeyCmdByronKeyParseError Text
errTxt ->
Text -> Doc ann
forall a ann. Pretty a => a -> Doc ann
forall ann. Text -> Doc ann
pretty Text
errTxt
KeyCmdItnKeyConvError ItnKeyConversionError
convErr ->
ItnKeyConversionError -> Doc ann
forall ann. ItnKeyConversionError -> Doc ann
renderConversionError ItnKeyConversionError
convErr
KeyCmdError
KeyCmdWrongKeyTypeError ->
Doc ann
"Please use a signing key file when converting ITN BIP32 or Extended keys"
KeyCmdCardanoAddressSigningKeyFileError FileError CardanoAddressSigningKeyConversionError
fileErr ->
FileError CardanoAddressSigningKeyConversionError -> Doc ann
forall e ann. Error e => e -> Doc ann
forall ann.
FileError CardanoAddressSigningKeyConversionError -> Doc ann
prettyError FileError CardanoAddressSigningKeyConversionError
fileErr
KeyCmdNonLegacyKey String
fp ->
Doc ann
"Signing key at: "
Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> String -> Doc ann
forall ann. String -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty String
fp
Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
" is not a legacy Byron signing key and should not need to be converted."
KeyCmdVerificationKeyReadError VerificationKeyTextOrFileError
e ->
VerificationKeyTextOrFileError -> Doc ann
forall ann. VerificationKeyTextOrFileError -> Doc ann
renderVerificationKeyTextOrFileError VerificationKeyTextOrFileError
e
KeyCmdExpectedExtendedVerificationKey SomeAddressVerificationKey
someVerKey ->
Doc ann
"Expected an extended verification key but got: "
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 (SomeAddressVerificationKey -> Text
renderSomeAddressVerificationKey SomeAddressVerificationKey
someVerKey)