~ubuntu-branches/ubuntu/raring/agda/raring-proposed

« back to all changes in this revision

Viewing changes to src/full/Agda/Interaction/Exceptions.hs

  • Committer: Bazaar Package Importer
  • Author(s): Iain Lane
  • Date: 2009-07-20 19:49:41 UTC
  • Revision ID: james.westby@ubuntu.com-20090720194941-hcjy91vrn16csh7d
Tags: upstream-2.2.4+dfsg
ImportĀ upstreamĀ versionĀ 2.2.4+dfsg

Show diffs side-by-side

added added

removed removed

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