mirror of
https://github.com/chrisdone-archive/duet.git
synced 2024-11-22 11:47:53 +03:00
Display errors instead of printing
This commit is contained in:
parent
cfda673f1d
commit
c8d85590c9
33
app/Main.hs
33
app/Main.hs
@ -15,6 +15,7 @@ import Control.Monad.Writer
|
||||
import qualified Data.Map.Strict as M
|
||||
import Data.Semigroup ((<>))
|
||||
import Duet.Context
|
||||
import Duet.Errors
|
||||
import Duet.Infer
|
||||
import Duet.Parser
|
||||
import Duet.Printer
|
||||
@ -108,20 +109,24 @@ runClassesPrint _ = do
|
||||
|
||||
runProgram :: Run -> IO ()
|
||||
runProgram run@Run {..} = do
|
||||
decls <- parseFile runInputFile
|
||||
runNoLoggingT
|
||||
(evalSupplyT
|
||||
(do (binds, ctx) <- createContext decls
|
||||
things <-
|
||||
execWriterT
|
||||
(runStepperIO
|
||||
run
|
||||
runSteps
|
||||
ctx
|
||||
(fmap (fmap typeSignatureA) binds)
|
||||
runMainIs)
|
||||
pure things)
|
||||
[1 ..])
|
||||
catch
|
||||
(catch
|
||||
(runNoLoggingT
|
||||
(evalSupplyT
|
||||
(do decls <- liftIO (parseFile runInputFile)
|
||||
(binds, ctx) <- createContext decls
|
||||
things <-
|
||||
execWriterT
|
||||
(runStepperIO
|
||||
run
|
||||
runSteps
|
||||
ctx
|
||||
(fmap (fmap typeSignatureA) binds)
|
||||
runMainIs)
|
||||
pure things)
|
||||
[1 ..]))
|
||||
(putStrLn . displayContextException))
|
||||
(putStrLn . displayParseException)
|
||||
|
||||
-- | Run the substitution model on the code.
|
||||
runStepperIO ::
|
||||
|
@ -4,15 +4,36 @@
|
||||
|
||||
module Duet.Errors where
|
||||
|
||||
import Control.Exception
|
||||
import Data.Char
|
||||
import Data.Function
|
||||
import Data.List
|
||||
import qualified Data.Map.Strict as M
|
||||
import Data.Ord
|
||||
import Data.Typeable
|
||||
import Duet.Printer
|
||||
import Duet.Types
|
||||
import Text.EditDistance
|
||||
|
||||
displayContextException :: ContextException -> String
|
||||
displayContextException (ContextException specialTypes (SomeException se)) =
|
||||
maybe
|
||||
(maybe
|
||||
(maybe
|
||||
(maybe
|
||||
(maybe
|
||||
(displayException se)
|
||||
(displayRenamerException specialTypes)
|
||||
(cast se))
|
||||
(displayInferException specialTypes)
|
||||
(cast se))
|
||||
(displayStepperException specialTypes)
|
||||
(cast se))
|
||||
(displayResolveException specialTypes)
|
||||
(cast se))
|
||||
displayParseException
|
||||
(cast se)
|
||||
|
||||
displayParseException :: ParseException -> String
|
||||
displayParseException e =
|
||||
case e of
|
||||
|
@ -217,9 +217,8 @@ data RenamerException
|
||||
deriving (Show, Generic, Data, Typeable, Typeable)
|
||||
instance Exception RenamerException
|
||||
|
||||
|
||||
data ContextException = ContextException (SpecialTypes Name) RenamerException
|
||||
deriving (Show, Generic, Data, Typeable, Typeable)
|
||||
data ContextException = ContextException (SpecialTypes Name) SomeException
|
||||
deriving (Show, Generic, Typeable)
|
||||
instance Exception ContextException
|
||||
|
||||
-- | An exception that may be thrown when reading in source code,
|
||||
|
Loading…
Reference in New Issue
Block a user