Port file was not written to... where? (#11108)

* Port file was not written to... where?

Adds the information on where the port file could not be written.
From the current phrasing it appears the intention was to add the
information but ultimately wasn't.

changelog_begin
changelog_end

* Address https://github.com/digital-asset/daml/pull/11108#pullrequestreview-770115835
This commit is contained in:
Stefano Baghino 2021-10-04 17:21:56 +02:00 committed by GitHub
parent a8d703b996
commit 4860271a53
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

View File

@ -19,6 +19,7 @@ import Control.Concurrent (threadDelay)
import Control.Exception.Safe (IOException, catchJust, mask, onException)
import Control.Monad
import qualified Data.Text.IO as T
import Data.Text (pack)
import Safe (readMay)
import System.Environment (getEnvironment)
import System.Exit (exitFailure)
@ -143,8 +144,8 @@ nullDevice
| otherwise = "/dev/null"
readPortFile :: Int -> String -> IO Int
readPortFile 0 _file = do
T.hPutStrLn stderr "Port file was not written to in time."
readPortFile 0 file = do
T.hPutStrLn stderr ("Port file was not written to '" <> pack file <> "' in time.")
exitFailure
readPortFile n file = do
fileContent <- catchJust (guard . shouldCatch) (readFile file) (const $ pure "")

View File

@ -8,14 +8,15 @@ import Control.Concurrent
import Control.Exception
import Control.Monad
import qualified Data.Text.IO as T
import Data.Text (pack)
import Safe (readMay)
import System.Exit
import System.IO
import System.IO.Error
readPortFile :: Int -> String -> IO Int
readPortFile 0 _file = do
T.hPutStrLn stderr "Port file was not written to in time."
readPortFile 0 file = do
T.hPutStrLn stderr ("Port file was not written to '" <> pack file <> "' in time.")
exitFailure
readPortFile n file = do
fileContent <- catchJust (guard . shouldCatch) (readFile file) (const $ pure "")