From 926215b6df99b4d3dace5dde900180ef66a3e830 Mon Sep 17 00:00:00 2001 From: John Ky Date: Fri, 17 Nov 2023 21:18:57 +1100 Subject: [PATCH] Error instance for FileError instead of Pretty --- cardano-api/internal/Cardano/Api/Error.hs | 4 ++-- cardano-api/internal/Cardano/Api/Pretty.hs | 2 ++ cardano-api/test/cardano-api-test/Test/Cardano/Api/IO.hs | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/cardano-api/internal/Cardano/Api/Error.hs b/cardano-api/internal/Cardano/Api/Error.hs index 22db12546f..a27f2edaa6 100644 --- a/cardano-api/internal/Cardano/Api/Error.hs +++ b/cardano-api/internal/Cardano/Api/Error.hs @@ -67,8 +67,8 @@ data FileError e = FileError FilePath e | FileIOError FilePath IOException deriving (Show, Eq, Functor) -instance Error e => Pretty (FileError e) where - pretty = \case +instance Error e => Error (FileError e) where + prettyError = \case FileErrorTempFile targetPath tempPath h -> vsep [ "Error creating temporary file at: " <> pretty tempPath diff --git a/cardano-api/internal/Cardano/Api/Pretty.hs b/cardano-api/internal/Cardano/Api/Pretty.hs index b5cff832d3..86d825452f 100644 --- a/cardano-api/internal/Cardano/Api/Pretty.hs +++ b/cardano-api/internal/Cardano/Api/Pretty.hs @@ -24,6 +24,8 @@ import qualified Data.Text.Lazy as TextLazy import Prettyprinter import Prettyprinter.Render.Terminal +-- | 'Ann' is the prettyprinter annotation for cardano-api and cardano-cli to enable the printing +-- of colored output. This is a type alias for AnsiStyle. type Ann = AnsiStyle newtype ShowOf a = ShowOf a diff --git a/cardano-api/test/cardano-api-test/Test/Cardano/Api/IO.hs b/cardano-api/test/cardano-api-test/Test/Cardano/Api/IO.hs index 7186934c22..7d5831f65d 100644 --- a/cardano-api/test/cardano-api-test/Test/Cardano/Api/IO.hs +++ b/cardano-api/test/cardano-api-test/Test/Cardano/Api/IO.hs @@ -26,7 +26,7 @@ prop_createVrfFileWithOwnerPermissions = result <- liftIO $ writeLazyByteStringFileWithOwnerPermissions (File file) "" case result of - Left err -> failWith Nothing $ prettyToString $ pretty @(FileError ()) err + Left err -> failWith Nothing $ prettyToString $ prettyError @(FileError ()) err Right () -> return () fResult <- liftIO . runExceptT $ checkVrfFilePermissions (File file)