{-# LANGUAGE DataKinds #-}
{-# LANGUAGE LambdaCase #-}

module Cardano.CLI.Types.Errors.TextViewFileError
  ( TextViewFileError (..)
  , renderTextViewFileError
  )
where

import           Cardano.Api

import           Cardano.CLI.Helpers (HelpersError, renderHelpersError)

data TextViewFileError
  = TextViewReadFileError (FileError TextEnvelopeError)
  | TextViewCBORPrettyPrintError !HelpersError
  deriving Int -> TextViewFileError -> ShowS
[TextViewFileError] -> ShowS
TextViewFileError -> String
(Int -> TextViewFileError -> ShowS)
-> (TextViewFileError -> String)
-> ([TextViewFileError] -> ShowS)
-> Show TextViewFileError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TextViewFileError -> ShowS
showsPrec :: Int -> TextViewFileError -> ShowS
$cshow :: TextViewFileError -> String
show :: TextViewFileError -> String
$cshowList :: [TextViewFileError] -> ShowS
showList :: [TextViewFileError] -> ShowS
Show

renderTextViewFileError :: TextViewFileError -> Doc ann
renderTextViewFileError :: forall ann. TextViewFileError -> Doc ann
renderTextViewFileError = \case
  TextViewReadFileError 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
  TextViewCBORPrettyPrintError HelpersError
hlprsErr ->
    Doc ann
"Error pretty printing CBOR: " Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> HelpersError -> Doc ann
forall ann. HelpersError -> Doc ann
renderHelpersError HelpersError
hlprsErr