hsp-0.7.3: src/HSP/Exception.hs
{-# LANGUAGE CPP, DeriveDataTypeable #-}
-----------------------------------------------------------------------------
-- |
-- Module : HSP.Exception
-- Copyright : (c) Niklas Broberg 2008
-- License : BSD-style (see the file LICENSE.txt)
--
-- Maintainer : Niklas Broberg, nibro@cs.chalmers.se
-- Stability : experimental
-- Portability : needs dynamic exceptions and deriving Typeable
--
-- Defines a datatype for runtime exceptions that may arise during
-- the evaluation of a HSP page.
-----------------------------------------------------------------------------
module HSP.Exception (
Exception(..),
throwHSP
) where
import Data.Typeable
#ifdef BASE46
import qualified Control.Exception (Exception, throw)
#else
import Control.OldException (throwDyn)
#endif
data Exception
= ParameterLookupFailed String -- ^ User tried to do an irrefutable parameter lookup
-- that failed.
-- | ... I'm sure there should be more exceptions, we'll add them when we get to them.
deriving (Eq, Show, Typeable)
#ifdef BASE46
instance Control.Exception.Exception Exception
#endif
-- Internal funcion that throws a dynamic exception particular to HSP.
throwHSP :: Exception -> a
#ifdef BASE46
throwHSP = Control.Exception.throw
#else
throwHSP = throwDyn
#endif