Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused error constructors #5041

Merged
merged 1 commit into from
Mar 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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