{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE DeriveDataTypeable #-}

module Text.CSL.Exception (CiteprocException(..), renderError) where
import Prelude
import           Control.Exception (Exception)
import           Data.Data

data CiteprocException =
       ErrorParsingReferences String
     | CouldNotFindAbbrevFile String
     | CouldNotFindBibFile    String
     | ErrorReadingBibFile    String String
     | ErrorReadingBib        String
     | ErrorSplittingDate
     | MacroNotFound          String
     | DependentStyleHasItselfAsParent String
     deriving (Int -> CiteprocException -> ShowS
[CiteprocException] -> ShowS
CiteprocException -> String
(Int -> CiteprocException -> ShowS)
-> (CiteprocException -> String)
-> ([CiteprocException] -> ShowS)
-> Show CiteprocException
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CiteprocException] -> ShowS
$cshowList :: [CiteprocException] -> ShowS
show :: CiteprocException -> String
$cshow :: CiteprocException -> String
showsPrec :: Int -> CiteprocException -> ShowS
$cshowsPrec :: Int -> CiteprocException -> ShowS
Show, Typeable CiteprocException
DataType
Constr
Typeable CiteprocException =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g)
 -> CiteprocException
 -> c CiteprocException)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c CiteprocException)
-> (CiteprocException -> Constr)
-> (CiteprocException -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c CiteprocException))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c CiteprocException))
-> ((forall b. Data b => b -> b)
    -> CiteprocException -> CiteprocException)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> CiteprocException -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> CiteprocException -> r)
-> (forall u.
    (forall d. Data d => d -> u) -> CiteprocException -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> CiteprocException -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> CiteprocException -> m CiteprocException)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> CiteprocException -> m CiteprocException)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> CiteprocException -> m CiteprocException)
-> Data CiteprocException
CiteprocException -> DataType
CiteprocException -> Constr
(forall b. Data b => b -> b)
-> CiteprocException -> CiteprocException
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CiteprocException -> c CiteprocException
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CiteprocException
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u.
Int -> (forall d. Data d => d -> u) -> CiteprocException -> u
forall u. (forall d. Data d => d -> u) -> CiteprocException -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> CiteprocException -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> CiteprocException -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> CiteprocException -> m CiteprocException
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> CiteprocException -> m CiteprocException
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CiteprocException
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CiteprocException -> c CiteprocException
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c CiteprocException)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c CiteprocException)
$cDependentStyleHasItselfAsParent :: Constr
$cMacroNotFound :: Constr
$cErrorSplittingDate :: Constr
$cErrorReadingBib :: Constr
$cErrorReadingBibFile :: Constr
$cCouldNotFindBibFile :: Constr
$cCouldNotFindAbbrevFile :: Constr
$cErrorParsingReferences :: Constr
$tCiteprocException :: DataType
gmapMo :: (forall d. Data d => d -> m d)
-> CiteprocException -> m CiteprocException
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> CiteprocException -> m CiteprocException
gmapMp :: (forall d. Data d => d -> m d)
-> CiteprocException -> m CiteprocException
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> CiteprocException -> m CiteprocException
gmapM :: (forall d. Data d => d -> m d)
-> CiteprocException -> m CiteprocException
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> CiteprocException -> m CiteprocException
gmapQi :: Int -> (forall d. Data d => d -> u) -> CiteprocException -> u
$cgmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> CiteprocException -> u
gmapQ :: (forall d. Data d => d -> u) -> CiteprocException -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> CiteprocException -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> CiteprocException -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> CiteprocException -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> CiteprocException -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> CiteprocException -> r
gmapT :: (forall b. Data b => b -> b)
-> CiteprocException -> CiteprocException
$cgmapT :: (forall b. Data b => b -> b)
-> CiteprocException -> CiteprocException
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c CiteprocException)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c CiteprocException)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c CiteprocException)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c CiteprocException)
dataTypeOf :: CiteprocException -> DataType
$cdataTypeOf :: CiteprocException -> DataType
toConstr :: CiteprocException -> Constr
$ctoConstr :: CiteprocException -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CiteprocException
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CiteprocException
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CiteprocException -> c CiteprocException
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CiteprocException -> c CiteprocException
$cp1Data :: Typeable CiteprocException
Data, Typeable)

instance Exception CiteprocException

renderError :: CiteprocException -> String
renderError :: CiteprocException -> String
renderError (ErrorParsingReferences s :: String
s) =
  "Error parsing references: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
s
renderError (CouldNotFindAbbrevFile s :: String
s) =
  "Could not find abbreviation file: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
s
renderError (CouldNotFindBibFile s :: String
s) =
  "Could not find bibliography file: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
s
renderError (ErrorReadingBibFile f :: String
f s :: String
s) =
  "Error reading bibliography " String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
f String -> ShowS
forall a. [a] -> [a] -> [a]
++ " " String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
s
renderError (ErrorReadingBib s :: String
s) =
  "Error reading bibliography " String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
s
renderError ErrorSplittingDate =
  "Error splitting date"
renderError (MacroNotFound s :: String
s) =
  "Macro not found: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
s
renderError (DependentStyleHasItselfAsParent s :: String
s) =
  "Dependent style " String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
s String -> ShowS
forall a. [a] -> [a] -> [a]
++ " has itself as parent"