Skip to content

Commit

Permalink
Merge pull request #5041 from input-output-hk/newhoggy/remove-unused-…
Browse files Browse the repository at this point in the history
…error-constructors

Remove unused error constructors
  • Loading branch information
newhoggy authored Mar 31, 2023
2 parents 3759680 + 85651fb commit 2e5e829
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 38 deletions.
29 changes: 2 additions & 27 deletions cardano-cli/src/Cardano/CLI/Shelley/Run/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ import qualified Ouroboros.Consensus.HardFork.History as Consensus
import qualified Ouroboros.Consensus.HardFork.History.Qry as Qry
import qualified Ouroboros.Consensus.Protocol.Abstract as Consensus
import qualified Ouroboros.Consensus.Protocol.Praos.Common as Consensus
import qualified Ouroboros.Network.Protocol.LocalStateQuery.Type as LocalStateQuery

import Control.Monad (forM, forM_, join)
import Control.Monad.IO.Class (MonadIO)
Expand Down Expand Up @@ -124,7 +123,6 @@ data ShelleyQueryCmdError
| ShelleyQueryCmdAcquireFailure !AcquiringFailure
| ShelleyQueryCmdEraConsensusModeMismatch !AnyConsensusMode !AnyCardanoEra
| ShelleyQueryCmdByronEra
| ShelleyQueryCmdPoolIdError (Hash StakePoolKey)
| ShelleyQueryCmdEraMismatch !EraMismatch
| ShelleyQueryCmdUnsupportedMode !AnyConsensusMode
| ShelleyQueryCmdPastHorizon !Qry.PastHorizonException
Expand All @@ -133,13 +131,8 @@ data ShelleyQueryCmdError
| ShelleyQueryCmdLeaderShipError !LeadershipError
| ShelleyQueryCmdTextEnvelopeReadError !(FileError TextEnvelopeError)
| ShelleyQueryCmdTextReadError !(FileError InputDecodeError)
| ShelleyQueryCmdColdKeyReadFileError !(FileError InputDecodeError)
| ShelleyQueryCmdOpCertCounterReadError !(FileError TextEnvelopeError)
| ShelleyQueryCmdProtocolStateDecodeFailure !(LBS.ByteString, DecoderError)
| ShelleyQueryCmdSlotToUtcError Text
| ShelleyQueryCmdNodeUnknownStakePool
FilePath
-- ^ Operational certificate of the unknown stake pool.
| ShelleyQueryCmdPoolStateDecodeError DecoderError
| ShelleyQueryCmdStakeSnapshotDecodeError DecoderError
| ShelleyQueryCmdUnsupportedNtcVersion !UnsupportedNtcVersionError
Expand All @@ -155,7 +148,6 @@ renderShelleyQueryCmdError err =
ShelleyQueryCmdHelpersError helpersErr -> renderHelpersError helpersErr
ShelleyQueryCmdAcquireFailure acquireFail -> Text.pack $ show acquireFail
ShelleyQueryCmdByronEra -> "This query cannot be used for the Byron era"
ShelleyQueryCmdPoolIdError poolId -> "The pool id does not exist: " <> textShow poolId
ShelleyQueryCmdEraConsensusModeMismatch (AnyConsensusMode cMode) (AnyCardanoEra era) ->
"Consensus mode and era mismatch. Consensus mode: " <> textShow cMode <>
" Era: " <> textShow era
Expand All @@ -168,16 +160,10 @@ renderShelleyQueryCmdError err =
ShelleyQueryCmdGenesisReadError err' -> Text.pack $ displayError err'
ShelleyQueryCmdLeaderShipError e -> Text.pack $ displayError e
ShelleyQueryCmdTextEnvelopeReadError e -> Text.pack $ displayError e
ShelleyQueryCmdSlotToUtcError e -> "Failed to convert slot to UTC time: " <> e
ShelleyQueryCmdTextReadError e -> Text.pack $ displayError e
ShelleyQueryCmdColdKeyReadFileError e -> Text.pack $ displayError e
ShelleyQueryCmdOpCertCounterReadError e -> Text.pack $ displayError e
ShelleyQueryCmdProtocolStateDecodeFailure (_, decErr) ->
"Failed to decode the protocol state: " <> toStrict (toLazyText $ build decErr)
ShelleyQueryCmdNodeUnknownStakePool nodeOpCert ->
Text.pack $ "The stake pool associated with: " <> nodeOpCert <> " was not found. Ensure the correct KES key has been " <>
"specified and that the stake pool is registered. If you have submitted a stake pool registration certificate " <>
"in the current epoch, you must wait until the following epoch for the registration to take place."
ShelleyQueryCmdPoolStateDecodeError decoderError ->
"Failed to decode PoolState. Error: " <> Text.pack (show decoderError)
ShelleyQueryCmdStakeSnapshotDecodeError decoderError ->
Expand Down Expand Up @@ -848,28 +834,17 @@ runQueryStakeAddressInfo (AnyConsensusModeParams cModeParams)
-- -------------------------------------------------------------------------------------------------

-- | An error that can occur while querying a node's local state.
data ShelleyQueryCmdLocalStateQueryError
= AcquireFailureError !LocalStateQuery.AcquireFailure
| EraMismatchError !EraMismatch
newtype ShelleyQueryCmdLocalStateQueryError
= EraMismatchError EraMismatch
-- ^ A query from a certain era was applied to a ledger from a different
-- era.
| ByronProtocolNotSupportedError
-- ^ The query does not support the Byron protocol.
| ShelleyProtocolEraMismatch
-- ^ The Shelley protocol only supports the Shelley era.
deriving (Eq, Show)

renderLocalStateQueryError :: ShelleyQueryCmdLocalStateQueryError -> Text
renderLocalStateQueryError lsqErr =
case lsqErr of
AcquireFailureError err -> "Local state query acquire failure: " <> textShow err
EraMismatchError err ->
"A query from a certain era was applied to a ledger from a different era: " <> textShow err
ByronProtocolNotSupportedError ->
"The attempted local state query does not support the Byron protocol."
ShelleyProtocolEraMismatch ->
"The Shelley protocol mode can only be used with the Shelley era, "
<> "i.e. with --shelley-mode use --shelley-era flag"

writeStakeAddressInfo
:: Maybe OutputFile
Expand Down
11 changes: 0 additions & 11 deletions cardano-cli/src/Cardano/CLI/Shelley/Run/Transaction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ data ShelleyTxCmdError
| ShelleyTxCmdScriptFileError (FileError ScriptDecodeError)
| ShelleyTxCmdReadTextViewFileError !(FileError TextEnvelopeError)
| ShelleyTxCmdReadWitnessSigningDataError !ReadWitnessSigningDataError
| ShelleyTxCmdRequiredSignerByronKeyError !SigningKeyFile
| ShelleyTxCmdWriteFileError !(FileError ())
| ShelleyTxCmdEraConsensusModeMismatch
!(Maybe FilePath)
Expand All @@ -83,8 +82,6 @@ data ShelleyTxCmdError
| ShelleyTxCmdTxBodyError !TxBodyError
| ShelleyTxCmdNotImplemented !Text
| ShelleyTxCmdWitnessEraMismatch !AnyCardanoEra !AnyCardanoEra !WitnessFile
| ShelleyTxCmdScriptLanguageNotSupportedInEra !AnyScriptLanguage !AnyCardanoEra
| ShelleyTxCmdReferenceScriptsNotSupportedInEra !AnyCardanoEra
| ShelleyTxCmdPolicyIdsMissing ![PolicyId]
| ShelleyTxCmdPolicyIdsExcess ![PolicyId]
| ShelleyTxCmdUnsupportedMode !AnyConsensusMode
Expand Down Expand Up @@ -133,8 +130,6 @@ renderShelleyTxCmdError err =
ShelleyTxCmdScriptFileError fileErr -> Text.pack (displayError fileErr)
ShelleyTxCmdReadWitnessSigningDataError witSignDataErr ->
renderReadWitnessSigningDataError witSignDataErr
ShelleyTxCmdRequiredSignerByronKeyError (SigningKeyFile fp) ->
"Byron key witness was used as a required signer: " <> textShow fp
ShelleyTxCmdWriteFileError fileErr -> Text.pack (displayError fileErr)
ShelleyTxCmdSocketEnvError envSockErr -> renderEnvSocketError envSockErr
ShelleyTxCmdTxSubmitError res -> "Error while submitting tx: " <> res
Expand Down Expand Up @@ -167,10 +162,6 @@ renderShelleyTxCmdError err =
"The transaction is for the " <> renderEra era <> " era, but the " <>
"witness in " <> textShow file <> " is for the " <> renderEra era' <> " era."

ShelleyTxCmdScriptLanguageNotSupportedInEra (AnyScriptLanguage lang) era ->
"The script language " <> textShow lang <> " is not supported in the " <>
renderEra era <> " era."

ShelleyTxCmdEraConsensusModeMismatch fp mode era ->
"Submitting " <> renderEra era <> " era transaction (" <> textShow fp <>
") is not supported in the " <> renderMode mode <> " consensus mode."
Expand Down Expand Up @@ -207,8 +198,6 @@ renderShelleyTxCmdError err =
[ "Execution units not available in the protocol parameters. This is "
, "likely due to not being in the Alonzo era"
]
ShelleyTxCmdReferenceScriptsNotSupportedInEra (AnyCardanoEra era) ->
"TxCmd: Reference scripts not supported in era: " <> textShow era
ShelleyTxCmdTxEraCastErr (EraCastError value fromEra toEra) ->
"Unable to cast era from " <> textShow fromEra <> " to " <> textShow toEra <> " the value " <> textShow value
ShelleyTxCmdQueryConvenienceError e ->
Expand Down

0 comments on commit 2e5e829

Please sign in to comment.