2
{-| This module defines the exception handler.
4
module Agda.Interaction.Exceptions where
6
import Control.OldException
7
import Control.Monad.Trans
9
import qualified System.IO.UTF8 as UTF8
11
import Agda.Syntax.Position
12
import Agda.Syntax.Parser ( ParseError(..) )
13
import Agda.Syntax.Concrete.Definitions ( DeclarationException(..) )
15
handleParseException :: (ParseError -> IO a) -> ParseError -> IO a
16
handleParseException crash e = crash e
18
handleDeclarationException :: (DeclarationException -> IO a) -> DeclarationException -> IO a
19
handleDeclarationException crash e = crash e
21
failOnException :: (Range -> String -> IO a) -> IO a -> IO a
22
failOnException h m = m `catchDyn` handleParseException handler
23
`catchDyn` handleDeclarationException handler
25
handler x = h (getRange x) (show x)