mirror of
https://github.com/serokell/haskell-with-utf8.git
synced 2024-10-26 07:51:16 +03:00
troubleshoot: Show listing locale-archive early
In case something bad happens with `localedef --list`, print the header early to make it clear what failed. Also, print the exception, if it happened.
This commit is contained in:
parent
b5451aa606
commit
f9aea084bb
@ -11,7 +11,7 @@ module Main (main) where
|
||||
|
||||
import Prelude hiding (print, putStr, putStrLn)
|
||||
|
||||
import Control.Exception.Safe (handleIO, tryIO)
|
||||
import Control.Exception.Safe (catchIO, tryIO)
|
||||
import Control.Monad (filterM, forM_)
|
||||
import Data.List (sort)
|
||||
import Data.Version (showVersion)
|
||||
@ -118,7 +118,8 @@ showLocales = do
|
||||
showLocaleList (lines out)
|
||||
Left _ -> do
|
||||
listDir "/usr/lib/locale"
|
||||
handleIO (\_ -> pure ()) $ listFile "/usr/lib/locale/locale-archive"
|
||||
listFile "/usr/lib/locale/locale-archive" `catchIO` \e ->
|
||||
putStrLn $ "<error>: " <> show e
|
||||
where
|
||||
showLocaleList :: [String] -> IO ()
|
||||
showLocaleList locales =
|
||||
@ -141,8 +142,8 @@ showLocales = do
|
||||
listFile path = doesPathExist path >>= \case
|
||||
False -> putStrLn $ " * " <> path <> " does not exist."
|
||||
True -> do
|
||||
out <- readProcess "localedef" ["--list", path] ""
|
||||
putStrLn $ " * " <> path <> ":"
|
||||
out <- readProcess "localedef" ["--list", path] ""
|
||||
showLocaleList (lines out)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user