xml-monad-0.4: Monadic extensions to the xml package.

Text.XML.Monad.Error

Contents

Synopsis

Error types

data XmlError Source

XML error type.

Constructors

EmptyDocument

An (invalid) empty input document was observed.

InvalidXml

Invalid XML, general parse error.

XmlChildNotFound

An immediate child element in an XML tree was not found.

XmlChildNotFoundQ QName

An immediate child element in an XML tree was not found, with name.

XmlElementNotFound

An element in an XML tree was not found.

XmlElementNotFoundQ QName

An element in an XML tree was not found, with name.

XmlAttributeNotFound

An XML element attribute was not found.

XmlAttributeNotFoundQ QName

An XML element attribute was not found, with name.

UnexpectedElementNameQ QName QName

An XML element name was different than expected, with actual and expected names.

XmlError String

A general XML error occured.

OtherError String

A general error occured.

UnspecifiedError

An unspecified general error occured.

class FromXmlError a whereSource

An error type that can be constructed from XmlError.

Methods

fromXmlError :: XmlError -> aSource

Construct error value.

Error handling

raise :: MonadError i m => i -> m aSource

Raise an exception.

maybeRaise :: MonadError i m => i -> Maybe a -> m aSource

Raise a defined exception for Nothing, return Just values.

raises :: MonadError i m => Either i a -> m aSource

Raise an exception for Left, return Right values.

asksEither :: (MonadReader s m, MonadError e m) => (s -> Either e a) -> m aSource

Like asks for a function that can return an error, as Left.

asksMaybe :: (MonadReader s m, MonadError e m) => e -> (s -> Maybe a) -> m aSource

Like asks for a function that can return an error, as Nothing.

try :: MonadError e m => m a -> m (Either e a)Source

Catch errors, and return an Left for errors, Right otherwise.

tryMaybe :: MonadError e m => m a -> m (Maybe a)Source

Catch errors (like try), and return Nothing for errors.

tryBool :: MonadError e m => m a -> m BoolSource

Catch errors (like try), and return False for errors and True for success.