Skip to content

Commit

Permalink
a bit more refactoring - warnings can always be reported, even if an …
Browse files Browse the repository at this point in the history
…error occurs in later tests
  • Loading branch information
nevrome committed Dec 8, 2023
1 parent cbc66f0 commit 73763b2
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions src/Poseidon/Janno.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1012,19 +1012,17 @@ readJannoFileRow jannoPath (lineNumber, row) = do
return $ Left $ PoseidonFileRowException jannoPath (show lineNumber) betterError
Right jannoRow -> do
let (errOrJannoRow, warnings) = W.runWriter (E.runExceptT (checkJannoRowConsistency jannoRow))
mapM_ (logWarning . renderWarning) warnings
case errOrJannoRow of
Left e -> return $ Left $
PoseidonFileRowException jannoPath renderLocation e
Right r -> do
mapM_ (logWarning . renderWarning) warnings
return $ Right r
where
renderWarning :: String -> String
renderWarning e = "Issue in " ++ jannoPath ++ " " ++
"in line " ++ renderLocation ++ ": " ++ e
renderLocation :: String
renderLocation = show lineNumber ++
" (Poseidon_ID: " ++ jPoseidonID jannoRow ++ ")"
Left e -> return $ Left $ PoseidonFileRowException jannoPath renderLocation e
Right r -> return $ Right r
where
renderWarning :: String -> String
renderWarning e = "Issue in " ++ jannoPath ++ " " ++
"in line " ++ renderLocation ++ ": " ++ e
renderLocation :: String
renderLocation = show lineNumber ++
" (Poseidon_ID: " ++ jPoseidonID jannoRow ++ ")"

decodingOptions :: Csv.DecodeOptions
decodingOptions = Csv.defaultDecodeOptions {
Expand Down

0 comments on commit 73763b2

Please sign in to comment.