Skip to content

Commit 50dbb31

Browse files
committed
Format ExitCodeException stdout and stderr with UTF-8
Closes #86
1 parent 793b2d8 commit 50dbb31

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

package.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ dependencies:
1919
- bytestring
2020
- process >=1.2
2121
- stm
22+
- text
2223
- transformers
2324
- unliftio-core
2425

src/System/Process/Typed/Internal.hs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ import qualified Data.ByteString.Lazy as L
2626
import qualified Data.ByteString.Lazy.Char8 as L8
2727
import Data.String (IsString (fromString))
2828
import Control.Monad.IO.Unlift
29+
import qualified Data.Text.Encoding.Error as TEE
30+
import qualified Data.Text.Lazy as TL
31+
import qualified Data.Text.Lazy.Encoding as TLE
2932

3033
#if MIN_VERSION_process(1, 4, 0) && !WINDOWS
3134
import System.Posix.Types (GroupID, UserID)
@@ -620,11 +623,13 @@ instance Show ExitCodeException where
620623
, show (eceProcessConfig ece) { pcEnv = Nothing }
621624
, if L.null (eceStdout ece)
622625
then ""
623-
else "Standard output:\n\n" ++ L8.unpack (eceStdout ece)
626+
else "Standard output:\n\n" ++ unpack (eceStdout ece)
624627
, if L.null (eceStderr ece)
625628
then ""
626-
else "Standard error:\n\n" ++ L8.unpack (eceStderr ece)
629+
else "Standard error:\n\n" ++ unpack (eceStderr ece)
627630
]
631+
where
632+
unpack = TL.unpack . TLE.decodeUtf8With TEE.lenientDecode
628633

629634
-- | Wrapper for when an exception is thrown when reading from a child
630635
-- process, used by 'byteStringOutput'.

0 commit comments

Comments
 (0)