mirror of
https://github.com/ilyakooo0/ormolu.git
synced 2024-09-19 04:37:08 +03:00
Don't wrap Ormolu exceptions as GHC errors
Turns out when ‘--unsafe’ is not set, exceptions thrown in formatting code are caught in the subsequent parsing check, which wraps them as GHC errors adding a text like: Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug Which is misleading since the error is not caused by GHC. This PR avoids it by strictly binding the result of ‘printModule’.
This commit is contained in:
parent
10232b9c86
commit
dde569e918
@ -1,5 +1,6 @@
|
|||||||
-- | A formatter for Haskell source code.
|
-- | A formatter for Haskell source code.
|
||||||
|
|
||||||
|
{-# LANGUAGE BangPatterns #-}
|
||||||
{-# LANGUAGE RecordWildCards #-}
|
{-# LANGUAGE RecordWildCards #-}
|
||||||
|
|
||||||
module Ormolu
|
module Ormolu
|
||||||
@ -55,7 +56,12 @@ ormolu cfg path str = do
|
|||||||
traceM "warnings:\n"
|
traceM "warnings:\n"
|
||||||
traceM (concatMap showWarn ws)
|
traceM (concatMap showWarn ws)
|
||||||
traceM (prettyPrintParseResult result0)
|
traceM (prettyPrintParseResult result0)
|
||||||
let txt = printModule (cfgDebug cfg) result0
|
-- NOTE We're forcing 'txt' here because otherwise errors (such as
|
||||||
|
-- messages about not-yet-supported functionality) will be thrown later
|
||||||
|
-- when we try to parse the rendered code back, inside of GHC monad
|
||||||
|
-- wrapper which will lead to error messages presenting the exceptions as
|
||||||
|
-- GHC bugs.
|
||||||
|
let !txt = printModule (cfgDebug cfg) result0
|
||||||
when (not (cfgUnsafe cfg) || cfgCheckIdempotency cfg) $ do
|
when (not (cfgUnsafe cfg) || cfgCheckIdempotency cfg) $ do
|
||||||
let pathRendered = path ++ "<rendered>"
|
let pathRendered = path ++ "<rendered>"
|
||||||
-- Parse the result of pretty-printing again and make sure that AST
|
-- Parse the result of pretty-printing again and make sure that AST
|
||||||
|
Loading…
Reference in New Issue
Block a user