Automatically generate documentation from comments in R7RS Scheme code
git clone https://git.8pit.net/scmdoc.git
1-- | Data types used for error handling in SchemeDoc. 2module SchemeDoc.Error where 3 4import Control.Exception 5import qualified Text.ParserCombinators.Parsec as P 6 7import SchemeDoc.Types 8 9-- | A syntax error occuring during further processing of a S-expression10-- with a 'SchemeDoc.Format.Formatter'. Currently, only used by the11-- 'SchemeDoc.Format.Library' 'SchemeDoc.Format.Formatter'.12data SyntaxError13 = SyntaxError14 Sexp15 -- ^ The S-expression for which an errror occured.16 String17 -- ^ A human-readable description of the error.18 deriving (Show, Eq)1920-- | Helper function for creating a new syntax error for a21-- given S-expression with a given error message.22makeErr :: Sexp -> String -> Either SyntaxError a23makeErr expr msg = Left $ SyntaxError expr msg2425------------------------------------------------------------------------2627-- | Exception occuring during the processing of a R7RS Scheme input.28--29-- Can either be a 'ErrParser' (occuring during inital parsing of30-- the input) or a 'ErrSyntax' (occuring during further processing of31-- parsed S-expressions).32data ExpandException = ErrParser P.ParseError | ErrSyntax SyntaxError33 deriving (Show)3435instance Exception ExpandException3637-- | Helper function to throw a 'SyntaxError'.38throwSyntax :: Sexp -> String -> IO a39throwSyntax e m = throwIO $ ErrSyntax (SyntaxError e m)