{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}

module Cardano.CLI.Types.Errors.ProtocolParamsError
  ( ProtocolParamsError (..)
  , renderProtocolParamsError
  )
where

import           Cardano.Api

import           Data.Text (Text)

data ProtocolParamsError
  = ProtocolParamsErrorFile (FileError ())
  | ProtocolParamsErrorJSON !FilePath !Text

renderProtocolParamsError :: ProtocolParamsError -> Doc ann
renderProtocolParamsError :: forall ann. ProtocolParamsError -> Doc ann
renderProtocolParamsError = \case
  ProtocolParamsErrorFile FileError ()
fileErr ->
    FileError () -> Doc ann
forall e ann. Error e => e -> Doc ann
forall ann. FileError () -> Doc ann
prettyError FileError ()
fileErr
  ProtocolParamsErrorJSON FilePath
fp Text
jsonErr ->
    Doc ann
"Error while decoding the protocol parameters at: " Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> FilePath -> Doc ann
forall a ann. Show a => a -> Doc ann
pshow FilePath
fp Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
" Error: " Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Text -> Doc ann
forall a ann. Show a => a -> Doc ann
pshow Text
jsonErr