xml-monad-0.5: 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.

UnexpectedElementContentQ String String

An XML element content was different than expected, with actual and expected contents.

UnexpectedAttributeNameQ QName QName

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

UnexpectedAttributeValueQ String String

An XML element attribute values was different than expected, with actual and expected values.

XmlError String

A general XML error occured.

EncodingError String

Data was encoded wrongly.

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.

raiseXml :: (MonadError i m, FromXmlError i) => XmlError -> m aSource

Raise an XML exception.

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

Raise a defined exception for Nothing, return Just values.

maybeRaiseXml :: (MonadError i m, FromXmlError i) => XmlError -> Maybe a -> m aSource

Raise a defined XML exception for Nothing, return Just values.

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

Raise an exception for Left, return Right values.

raisesXml :: (MonadError i m, FromXmlError i) => Either XmlError 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.

asksEitherXml :: (MonadReader s m, MonadError e m, FromXmlError e) => (s -> Either XmlError a) -> m aSource

Like asks for a function that can return an XML 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.

asksMaybeXml :: (MonadReader s m, MonadError e m, FromXmlError e) => XmlError -> (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.