relude-1.2.1.0: Safe, performant, user-friendly and lightweight Haskell Standard Library
Copyright(c) 2016 Stephen Diehl
(c) 2016-2018 Serokell
(c) 2018-2023 Kowainik
LicenseMIT
MaintainerKowainik <xrom.xkov@gmail.com>
StabilityStable
PortabilityPortable
Safe HaskellSafe
LanguageHaskell2010

Relude.Exception

Contents

Description

Re-exports most useful functionality from the Control.Exception module. Also provides some convenient utilities to throw and handle exceptions.

Synopsis

Control.Exception reexports

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

Minimal complete definition

Nothing

Instances

Instances details
Exception NestedAtomically 
Instance details

Defined in Control.Exception.Base

Methods

toException :: NestedAtomically -> SomeException #

fromException :: SomeException -> Maybe NestedAtomically #

displayException :: NestedAtomically -> String #

Exception NoMatchingContinuationPrompt 
Instance details

Defined in Control.Exception.Base

Methods

toException :: NoMatchingContinuationPrompt -> SomeException #

fromException :: SomeException -> Maybe NoMatchingContinuationPrompt #

displayException :: NoMatchingContinuationPrompt -> String #

Exception NoMethodError 
Instance details

Defined in Control.Exception.Base

Methods

toException :: NoMethodError -> SomeException #

fromException :: SomeException -> Maybe NoMethodError #

displayException :: NoMethodError -> String #

Exception NonTermination 
Instance details

Defined in Control.Exception.Base

Methods

toException :: NonTermination -> SomeException #

fromException :: SomeException -> Maybe NonTermination #

displayException :: NonTermination -> String #

Exception PatternMatchFail 
Instance details

Defined in Control.Exception.Base

Methods

toException :: PatternMatchFail -> SomeException #

fromException :: SomeException -> Maybe PatternMatchFail #

displayException :: PatternMatchFail -> String #

Exception RecConError 
Instance details

Defined in Control.Exception.Base

Methods

toException :: RecConError -> SomeException #

fromException :: SomeException -> Maybe RecConError #

displayException :: RecConError -> String #

Exception RecSelError 
Instance details

Defined in Control.Exception.Base

Methods

toException :: RecSelError -> SomeException #

fromException :: SomeException -> Maybe RecSelError #

displayException :: RecSelError -> String #

Exception RecUpdError 
Instance details

Defined in Control.Exception.Base

Methods

toException :: RecUpdError -> SomeException #

fromException :: SomeException -> Maybe RecUpdError #

displayException :: RecUpdError -> String #

Exception TypeError 
Instance details

Defined in Control.Exception.Base

Methods

toException :: TypeError -> SomeException #

fromException :: SomeException -> Maybe TypeError #

displayException :: TypeError -> String #

Exception Void 
Instance details

Defined in GHC.Exception.Type

Exception ErrorCall 
Instance details

Defined in GHC.Exception

Methods

toException :: ErrorCall -> SomeException #

fromException :: SomeException -> Maybe ErrorCall #

displayException :: ErrorCall -> String #

Exception ArithException 
Instance details

Defined in GHC.Exception.Type

Methods

toException :: ArithException -> SomeException #

fromException :: SomeException -> Maybe ArithException #

displayException :: ArithException -> String #

Exception SomeException 
Instance details

Defined in GHC.Exception.Type

Exception AllocationLimitExceeded 
Instance details

Defined in GHC.IO.Exception

Methods

toException :: AllocationLimitExceeded -> SomeException #

fromException :: SomeException -> Maybe AllocationLimitExceeded #

displayException :: AllocationLimitExceeded -> String #

Exception ArrayException 
Instance details

Defined in GHC.IO.Exception

Methods

toException :: ArrayException -> SomeException #

fromException :: SomeException -> Maybe ArrayException #

displayException :: ArrayException -> String #

Exception AssertionFailed 
Instance details

Defined in GHC.IO.Exception

Methods

toException :: AssertionFailed -> SomeException #

fromException :: SomeException -> Maybe AssertionFailed #

displayException :: AssertionFailed -> String #

Exception AsyncException 
Instance details

Defined in GHC.IO.Exception

Methods

toException :: AsyncException -> SomeException #

fromException :: SomeException -> Maybe AsyncException #

displayException :: AsyncException -> String #

Exception BlockedIndefinitelyOnMVar 
Instance details

Defined in GHC.IO.Exception

Methods

toException :: BlockedIndefinitelyOnMVar -> SomeException #

fromException :: SomeException -> Maybe BlockedIndefinitelyOnMVar #

displayException :: BlockedIndefinitelyOnMVar -> String #

Exception BlockedIndefinitelyOnSTM 
Instance details

Defined in GHC.IO.Exception

Methods

toException :: BlockedIndefinitelyOnSTM -> SomeException #

fromException :: SomeException -> Maybe BlockedIndefinitelyOnSTM #

displayException :: BlockedIndefinitelyOnSTM -> String #

Exception CompactionFailed 
Instance details

Defined in GHC.IO.Exception

Methods

toException :: CompactionFailed -> SomeException #

fromException :: SomeException -> Maybe CompactionFailed #

displayException :: CompactionFailed -> String #

Exception Deadlock 
Instance details

Defined in GHC.IO.Exception

Methods

toException :: Deadlock -> SomeException #

fromException :: SomeException -> Maybe Deadlock #

displayException :: Deadlock -> String #

Exception ExitCode 
Instance details

Defined in GHC.IO.Exception

Methods

toException :: ExitCode -> SomeException #

fromException :: SomeException -> Maybe ExitCode #

displayException :: ExitCode -> String #

Exception FixIOException 
Instance details

Defined in GHC.IO.Exception

Methods

toException :: FixIOException -> SomeException #

fromException :: SomeException -> Maybe FixIOException #

displayException :: FixIOException -> String #

Exception IOException 
Instance details

Defined in GHC.IO.Exception

Methods

toException :: IOException -> SomeException #

fromException :: SomeException -> Maybe IOException #

displayException :: IOException -> String #

Exception SomeAsyncException 
Instance details

Defined in GHC.IO.Exception

Methods

toException :: SomeAsyncException -> SomeException #

fromException :: SomeException -> Maybe SomeAsyncException #

displayException :: SomeAsyncException -> String #

Exception Bug Source # 
Instance details

Defined in Relude.Exception

Exception UnicodeException 
Instance details

Defined in Data.Text.Encoding.Error

data SomeException #

Constructors

Exception e => SomeException e 

Bugs

data Bug Source #

Type that represents exceptions used in cases when a particular codepath is not meant to be ever executed, but happens to be executed anyway.

Instances

Instances details
Exception Bug Source # 
Instance details

Defined in Relude.Exception

Show Bug Source # 
Instance details

Defined in Relude.Exception

Methods

showsPrec :: Int -> Bug -> ShowS

show :: Bug -> String

showList :: [Bug] -> ShowS

bug :: (HasCallStack, Exception e) => e -> a Source #

Generate a pure value which, when forced, will synchronously throw the exception wrapped into Bug data type.

pattern Exc :: Exception e => e -> SomeException Source #

Pattern synonym to easy pattern matching on exceptions. So instead of writing something like this:

isNonCriticalExc :: SomeException -> Bool
isNonCriticalExc e
    | Just (_ :: NodeAttackedError) <- fromException e = True
    | Just DialogUnexpected{} <- fromException e = True
    | otherwise = False

you can use Exc pattern synonym:

isNonCriticalExc :: SomeException -> Bool
isNonCriticalExc = case
    Exc (_ :: NodeAttackedError) -> True  -- matching all exceptions of type NodeAttackedError
    Exc DialogUnexpected{} -> True
    _ -> False

This pattern is bidirectional. You can use Exc e instead of toException e.