freckle-app-1.15.2.0: Haskell application toolkit used at Freckle
Safe HaskellSafe-Inferred
LanguageHaskell2010

Freckle.App.Exception.Types

Synopsis

Documentation

data ExceptionHandler m a Source #

Constructors

forall e.Exception e => ExceptionHandler (e -> m a) 

data AnnotatedException exception #

The AnnotatedException type wraps an exception with a [Annotation]. This can provide a sort of a manual stack trace with programmer provided data.

Since: annotated-exception-0.1.0.0

Constructors

AnnotatedException 

Fields

Instances

Instances details
Foldable AnnotatedException 
Instance details

Defined in Control.Exception.Annotated

Methods

fold :: Monoid m => AnnotatedException m -> m #

foldMap :: Monoid m => (a -> m) -> AnnotatedException a -> m #

foldMap' :: Monoid m => (a -> m) -> AnnotatedException a -> m #

foldr :: (a -> b -> b) -> b -> AnnotatedException a -> b #

foldr' :: (a -> b -> b) -> b -> AnnotatedException a -> b #

foldl :: (b -> a -> b) -> b -> AnnotatedException a -> b #

foldl' :: (b -> a -> b) -> b -> AnnotatedException a -> b #

foldr1 :: (a -> a -> a) -> AnnotatedException a -> a #

foldl1 :: (a -> a -> a) -> AnnotatedException a -> a #

toList :: AnnotatedException a -> [a] #

null :: AnnotatedException a -> Bool #

length :: AnnotatedException a -> Int #

elem :: Eq a => a -> AnnotatedException a -> Bool #

maximum :: Ord a => AnnotatedException a -> a #

minimum :: Ord a => AnnotatedException a -> a #

sum :: Num a => AnnotatedException a -> a #

product :: Num a => AnnotatedException a -> a #

Traversable AnnotatedException 
Instance details

Defined in Control.Exception.Annotated

Applicative AnnotatedException 
Instance details

Defined in Control.Exception.Annotated

Functor AnnotatedException 
Instance details

Defined in Control.Exception.Annotated

Exception exception => Exception (AnnotatedException exception)

This instance of Exception is a bit interesting. It tries to do as much hiding and packing and flattening as possible to ensure that even exception handling machinery outside of this package can still intelligently handle it.

Any Exception can be caught as a AnnotatedException with an empty context, so catching a AnnotatedException e will also catch a regular e and give it an empty set of annotations.

For the most up to date details, see the test suite.

Since: annotated-exception-0.1.0.0

Instance details

Defined in Control.Exception.Annotated

Show exception => Show (AnnotatedException exception) 
Instance details

Defined in Control.Exception.Annotated

Methods

showsPrec :: Int -> AnnotatedException exception -> ShowS #

show :: AnnotatedException exception -> String #

showList :: [AnnotatedException exception] -> ShowS #

class (Typeable e, Show e) => Exception e where #

Any type that you wish to throw or catch as an exception must be an instance of the Exception class. The simplest case is a new exception type directly below the root:

data MyException = ThisException | ThatException
    deriving Show

instance Exception MyException

The default method definitions in the Exception class do what we need in this case. You can now throw and catch ThisException and ThatException as exceptions:

*Main> throw ThisException `catch` \e -> putStrLn ("Caught " ++ show (e :: MyException))
Caught ThisException

In more complicated examples, you may wish to define a whole hierarchy of exceptions:

---------------------------------------------------------------------
-- Make the root exception type for all the exceptions in a compiler

data SomeCompilerException = forall e . Exception e => SomeCompilerException e

instance Show SomeCompilerException where
    show (SomeCompilerException e) = show e

instance Exception SomeCompilerException

compilerExceptionToException :: Exception e => e -> SomeException
compilerExceptionToException = toException . SomeCompilerException

compilerExceptionFromException :: Exception e => SomeException -> Maybe e
compilerExceptionFromException x = do
    SomeCompilerException a <- fromException x
    cast a

---------------------------------------------------------------------
-- Make a subhierarchy for exceptions in the frontend of the compiler

data SomeFrontendException = forall e . Exception e => SomeFrontendException e

instance Show SomeFrontendException where
    show (SomeFrontendException e) = show e

instance Exception SomeFrontendException where
    toException = compilerExceptionToException
    fromException = compilerExceptionFromException

frontendExceptionToException :: Exception e => e -> SomeException
frontendExceptionToException = toException . SomeFrontendException

frontendExceptionFromException :: Exception e => SomeException -> Maybe e
frontendExceptionFromException x = do
    SomeFrontendException a <- fromException x
    cast a

---------------------------------------------------------------------
-- Make an exception type for a particular frontend compiler exception

data MismatchedParentheses = MismatchedParentheses
    deriving Show

instance Exception MismatchedParentheses where
    toException   = frontendExceptionToException
    fromException = frontendExceptionFromException

We can now catch a MismatchedParentheses exception as MismatchedParentheses, SomeFrontendException or SomeCompilerException, but not other types, e.g. IOException:

*Main> throw MismatchedParentheses `catch` \e -> putStrLn ("Caught " ++ show (e :: MismatchedParentheses))
Caught MismatchedParentheses
*Main> throw MismatchedParentheses `catch` \e -> putStrLn ("Caught " ++ show (e :: SomeFrontendException))
Caught MismatchedParentheses
*Main> throw MismatchedParentheses `catch` \e -> putStrLn ("Caught " ++ show (e :: SomeCompilerException))
Caught MismatchedParentheses
*Main> throw MismatchedParentheses `catch` \e -> putStrLn ("Caught " ++ show (e :: IOException))
*** Exception: MismatchedParentheses

Minimal complete definition

Nothing

Methods

toException :: e -> SomeException #

fromException :: SomeException -> Maybe e #

displayException :: e -> String #

Render this exception value in a human-friendly manner.

Default implementation: show.

Since: base-4.8.0.0

Instances

Instances details
Exception HUnitFailure 
Instance details

Defined in Test.HUnit.Lang

Exception AesonException 
Instance details

Defined in Data.Aeson

Exception AsyncCancelled 
Instance details

Defined in Control.Concurrent.Async.Internal

Exception ExceptionInLinkedThread 
Instance details

Defined in Control.Concurrent.Async.Internal

Exception Void

Since: base-4.8.0.0

Instance details

Defined in GHC.Exception.Type

Exception ErrorCall

Since: base-4.0.0.0

Instance details

Defined in GHC.Exception

Exception ArithException

Since: base-4.0.0.0

Instance details

Defined in GHC.Exception.Type

Exception SomeException

Since: base-3.0

Instance details

Defined in GHC.Exception.Type

Exception AllocationLimitExceeded

Since: base-4.8.0.0

Instance details

Defined in GHC.IO.Exception

Exception ArrayException

Since: base-4.1.0.0

Instance details

Defined in GHC.IO.Exception

Exception AssertionFailed

Since: base-4.1.0.0

Instance details

Defined in GHC.IO.Exception

Exception AsyncException

Since: base-4.7.0.0

Instance details

Defined in GHC.IO.Exception

Exception BlockedIndefinitelyOnMVar

Since: base-4.1.0.0

Instance details

Defined in GHC.IO.Exception

Exception BlockedIndefinitelyOnSTM

Since: base-4.1.0.0

Instance details

Defined in GHC.IO.Exception

Exception CompactionFailed

Since: base-4.10.0.0

Instance details

Defined in GHC.IO.Exception

Exception Deadlock

Since: base-4.1.0.0

Instance details

Defined in GHC.IO.Exception

Exception ExitCode

Since: base-4.1.0.0

Instance details

Defined in GHC.IO.Exception

Exception FixIOException

Since: base-4.11.0.0

Instance details

Defined in GHC.IO.Exception

Exception IOException

Since: base-4.1.0.0

Instance details

Defined in GHC.IO.Exception

Exception SomeAsyncException

Since: base-4.7.0.0

Instance details

Defined in GHC.IO.Exception

Exception ASCII7_Invalid 
Instance details

Defined in Basement.String.Encoding.ASCII7

Methods

toException :: ASCII7_Invalid -> SomeException #

fromException :: SomeException -> Maybe ASCII7_Invalid #

displayException :: ASCII7_Invalid -> String #

Exception ISO_8859_1_Invalid 
Instance details

Defined in Basement.String.Encoding.ISO_8859_1

Methods

toException :: ISO_8859_1_Invalid -> SomeException #

fromException :: SomeException -> Maybe ISO_8859_1_Invalid #

displayException :: ISO_8859_1_Invalid -> String #

Exception UTF16_Invalid 
Instance details

Defined in Basement.String.Encoding.UTF16

Methods

toException :: UTF16_Invalid -> SomeException #

fromException :: SomeException -> Maybe UTF16_Invalid #

displayException :: UTF16_Invalid -> String #

Exception UTF32_Invalid 
Instance details

Defined in Basement.String.Encoding.UTF32

Methods

toException :: UTF32_Invalid -> SomeException #

fromException :: SomeException -> Maybe UTF32_Invalid #

displayException :: UTF32_Invalid -> String #

Exception DeserialiseFailure 
Instance details

Defined in Codec.CBOR.Read

Exception TextException 
Instance details

Defined in Data.Conduit.Text

Exception NotFoundException 
Instance details

Defined in Context.Internal

Exception CryptoError 
Instance details

Defined in Crypto.Error.Types

Exception CryptoError 
Instance details

Defined in Crypto.Error.Types

Exception HttpDecodeError Source # 
Instance details

Defined in Freckle.App.Http

Exception RetriesExhausted Source # 
Instance details

Defined in Freckle.App.Http.Retry

Exception ResultStatus 
Instance details

Defined in Test.Hspec.Core.Example

Exception EncapsulatedPopperException 
Instance details

Defined in Network.HTTP.Client.Request

Methods

toException :: EncapsulatedPopperException -> SomeException #

fromException :: SomeException -> Maybe EncapsulatedPopperException #

displayException :: EncapsulatedPopperException -> String #

Exception HttpException 
Instance details

Defined in Network.HTTP.Client.Types

Exception HttpExceptionContentWrapper 
Instance details

Defined in Network.HTTP.Client.Types

Methods

toException :: HttpExceptionContentWrapper -> SomeException #

fromException :: SomeException -> Maybe HttpExceptionContentWrapper #

displayException :: HttpExceptionContentWrapper -> String #

Exception JSONException 
Instance details

Defined in Network.HTTP.Simple

Exception KafkaError 
Instance details

Defined in Kafka.Types

Exception InvalidPosException 
Instance details

Defined in Text.Megaparsec.Pos

Exception NullError 
Instance details

Defined in Data.NonNull

Methods

toException :: NullError -> SomeException #

fromException :: SomeException -> Maybe NullError #

displayException :: NullError -> String #

Exception PersistentSqlException 
Instance details

Defined in Database.Persist.Sql.Types

Exception OnlyUniqueException 
Instance details

Defined in Database.Persist.Types.Base

Methods

toException :: OnlyUniqueException -> SomeException #

fromException :: SomeException -> Maybe OnlyUniqueException #

displayException :: OnlyUniqueException -> String #

Exception PersistException 
Instance details

Defined in Database.Persist.Types.Base

Exception UpdateException 
Instance details

Defined in Database.Persist.Types.Base

Exception PostgresServerVersionError 
Instance details

Defined in Database.Persist.Postgresql

Methods

toException :: PostgresServerVersionError -> SomeException #

fromException :: SomeException -> Maybe PostgresServerVersionError #

displayException :: PostgresServerVersionError -> String #

Exception ConstraintViolation 
Instance details

Defined in Database.PostgreSQL.Simple.Errors

Exception FormatError 
Instance details

Defined in Database.PostgreSQL.Simple.Internal

Exception QueryError 
Instance details

Defined in Database.PostgreSQL.Simple.Internal

Exception SomePostgreSqlException 
Instance details

Defined in Database.PostgreSQL.Simple.Internal

Exception SqlError 
Instance details

Defined in Database.PostgreSQL.Simple.Internal

Exception InvalidAccess 
Instance details

Defined in Control.Monad.Trans.Resource.Internal

Exception ResourceCleanupException 
Instance details

Defined in Control.Monad.Trans.Resource.Internal

Exception UnicodeException 
Instance details

Defined in Data.Text.Encoding.Error

Exception ByteStringOutputException 
Instance details

Defined in System.Process.Typed.Internal

Exception ExitCodeException 
Instance details

Defined in System.Process.Typed.Internal

Exception StringException

Since: unliftio-0.1.0.0

Instance details

Defined in UnliftIO.Exception

Exception ConcException 
Instance details

Defined in UnliftIO.Internals.Async

Exception HandlerContents 
Instance details

Defined in Yesod.Core.Types

Exception exception => Exception (AnnotatedException exception)

This instance of Exception is a bit interesting. It tries to do as much hiding and packing and flattening as possible to ensure that even exception handling machinery outside of this package can still intelligently handle it.

Any Exception can be caught as a AnnotatedException with an empty context, so catching a AnnotatedException e will also catch a regular e and give it an empty set of annotations.

For the most up to date details, see the test suite.

Since: annotated-exception-0.1.0.0

Instance details

Defined in Control.Exception.Annotated

(Show s, Show (Token s), Show e, ShowErrorComponent e, VisualStream s, Typeable s, Typeable e) => Exception (ParseError s e) 
Instance details

Defined in Text.Megaparsec.Error

(Show s, Show (Token s), Show e, ShowErrorComponent e, VisualStream s, TraversableStream s, Typeable s, Typeable e) => Exception (ParseErrorBundle s e) 
Instance details

Defined in Text.Megaparsec.Error

data SomeException #

The SomeException type is the root of the exception type hierarchy. When an exception of type e is thrown, behind the scenes it is encapsulated in a SomeException.

Constructors

Exception e => SomeException e 

type HasCallStack = ?callStack :: CallStack #

Request a CallStack.

NOTE: The implicit parameter ?callStack :: CallStack is an implementation detail and should not be considered part of the CallStack API, we may decide to change the implementation in the future.

Since: base-4.9.0.0