Skip to content

Commit 8cab3d1

Browse files
committed
Output exceptions to stderr using ByteString #422
1 parent 2b2f95c commit 8cab3d1

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/main/Main.hs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,14 @@
99

1010
module Main where
1111

12+
import Blaze.ByteString.Builder (toLazyByteString, copyByteString)
13+
import Blaze.ByteString.Builder.Char.Utf8 (fromShow)
1214
import Control.Exception
1315
import Control.Monad
1416
import Control.Monad.IO.Class
1517
import Control.Monad.Logger
1618
import Control.Monad.Reader (ask)
19+
import qualified Data.ByteString.Lazy as L
1720
import Data.Char (toLower)
1821
import Data.List
1922
import qualified Data.List as List
@@ -236,7 +239,7 @@ main =
236239
case fromException e of
237240
Just ec -> exitWith ec
238241
Nothing -> do
239-
print e
242+
L.hPut stderr $ toLazyByteString $ fromShow e <> copyByteString "\n"
240243
exitFailure
241244
where
242245
dockerHelpOptName = Docker.dockerCmdName ++ "-help"

stack.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ executable stack
167167
Plugins.Commands
168168

169169
build-depends: base >=4.7 && < 5
170+
, blaze-builder
170171
, bytestring >= 0.10.4.0
171172
, containers
172173
, exceptions

0 commit comments

Comments
 (0)