Skip to content
This repository was archived by the owner on Oct 16, 2019. It is now read-only.

Commit 2ffd117

Browse files
committed
Make it easier to parse the output of check-links
1 parent af426e1 commit 2ffd117

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

tools/check-links.hs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import qualified Network.HTTP.Types as Http
1919
import qualified Network.URI as Uri
2020
import qualified System.Directory as Directory
2121
import qualified System.FilePath as Path
22+
import qualified System.IO as IO
2223
import qualified Text.Printf as Printf
2324

2425
main :: IO ()
@@ -110,15 +111,15 @@ checkLink manager uri = do
110111
Exception.catch
111112
(do
112113
response <- Client.httpNoBody (withUserAgent request) manager
113-
Printf.printf
114-
"- %d %s\n"
115-
(Http.statusCode (Client.responseStatus response))
116-
url
114+
case Http.statusCode (Client.responseStatus response) of
115+
200 -> Printf.printf "- 200 %s\n" url
116+
code -> IO.hPutStrLn IO.stderr (Printf.printf "- %d %s" code url)
117117
)
118118
(\exception -> case exception of
119119
Client.HttpExceptionRequest _ x ->
120-
Printf.printf "- 001 %s %s\n" url (show x)
121-
Client.InvalidUrlException _ x -> Printf.printf "- 002 %s %s\n" url x
120+
IO.hPutStrLn IO.stderr (Printf.printf "- 001 %s %s" url (show x))
121+
Client.InvalidUrlException _ x ->
122+
IO.hPutStrLn IO.stderr (Printf.printf "- 002 %s %s" url x)
122123
)
123124

124125
displayUri :: Uri.URI -> String

0 commit comments

Comments
 (0)