ghc-lib-parser-9.8.3.20241022: The GHC API, decoupled from GHC versions
Safe HaskellIgnore
LanguageHaskell2010

GHC.Utils.Panic

Description

Defines basic functions for printing error messages.

It's hard to put these functions anywhere else without causing some unnecessary loops in the module dependency graph.

Synopsis

GHC exception type

data GhcException Source #

GHC's own exception type error messages all take the form:

     <location>: <error>
 

If the location is on the command line, or in GHC itself, then <location>="ghc". All of the error types below correspond to a <location> of "ghc", except for ProgramError (where the string is assumed to contain a location already, so we don't print one).

Constructors

Signal Int

Some other fatal signal (SIGHUP,SIGTERM)

UsageError String

Prints the short usage msg after the error

CmdLineError String

A problem with the command line arguments, but don't print usage.

Panic String

The impossible happened.

PprPanic String SDoc 
Sorry String

The user tickled something that's known not to work yet, but we're not counting it as a bug.

PprSorry String SDoc 
InstallationError String

An installation problem.

ProgramError String

An error in the user's code, probably.

PprProgramError String SDoc 

showGhcException :: SDocContext -> GhcException -> ShowS Source #

Append a description of the given exception to this string.

showGhcExceptionUnsafe :: GhcException -> ShowS Source #

Append a description of the given exception to this string.

Note that this uses defaultSDocContext, which doesn't use the options set by the user via DynFlags.

handleGhcException :: ExceptionMonad m => (GhcException -> m a) -> m a -> m a Source #

Command error throwing patterns

pgmError :: HasCallStack => String -> a Source #

Panics and asserts.

panic :: HasCallStack => String -> a Source #

Panics and asserts.

pprPanic :: HasCallStack => String -> SDoc -> a Source #

Throw an exception saying "bug in GHC" with a callstack

sorry :: HasCallStack => String -> a Source #

Panics and asserts.

panicDoc :: String -> SDoc -> a Source #

Throw an exception saying "bug in GHC"

sorryDoc :: String -> SDoc -> a Source #

Throw an exception saying "this isn't finished yet"

pgmErrorDoc :: String -> SDoc -> a Source #

Throw an exception saying "bug in pgm being compiled" (used for unusual program errors)

Assertions

assertPanic :: String -> Int -> a Source #

Throw a failed assertion exception for a given filename and line number.

assertPprPanic :: HasCallStack => SDoc -> a Source #

Panic with an assertion failure, recording the given file and line number. Should typically be accessed with the ASSERT family of macros

assertPpr :: HasCallStack => Bool -> SDoc -> a -> a Source #

assertPprM :: (HasCallStack, Monad m) => m Bool -> SDoc -> m () Source #

Call stacks

Exception utilities

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

Minimal complete definition

Nothing

Instances

Instances details
Exception NestedAtomically 
Instance details

Defined in Control.Exception.Base

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

Exception NonTermination 
Instance details

Defined in Control.Exception.Base

Exception PatternMatchFail 
Instance details

Defined in Control.Exception.Base

Exception RecConError 
Instance details

Defined in Control.Exception.Base

Exception RecSelError 
Instance details

Defined in Control.Exception.Base

Exception RecUpdError 
Instance details

Defined in Control.Exception.Base

Exception TypeError 
Instance details

Defined in Control.Exception.Base

Exception Dynamic 
Instance details

Defined in Data.Dynamic

Methods

toException :: Dynamic -> SomeException #

fromException :: SomeException -> Maybe Dynamic #

displayException :: Dynamic -> String #

Exception Void 
Instance details

Defined in GHC.Exception.Type

Exception ErrorCall 
Instance details

Defined in GHC.Exception

Exception ArithException 
Instance details

Defined in GHC.Exception.Type

Exception SomeException 
Instance details

Defined in GHC.Exception.Type

Exception AllocationLimitExceeded 
Instance details

Defined in GHC.IO.Exception

Exception ArrayException 
Instance details

Defined in GHC.IO.Exception

Exception AssertionFailed 
Instance details

Defined in GHC.IO.Exception

Exception AsyncException 
Instance details

Defined in GHC.IO.Exception

Exception BlockedIndefinitelyOnMVar 
Instance details

Defined in GHC.IO.Exception

Exception BlockedIndefinitelyOnSTM 
Instance details

Defined in GHC.IO.Exception

Exception CompactionFailed 
Instance details

Defined in GHC.IO.Exception

Exception Deadlock 
Instance details

Defined in GHC.IO.Exception

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

Exception SomeAsyncException 
Instance details

Defined in GHC.IO.Exception

Exception FileLockingNotSupported 
Instance details

Defined in GHC.IO.Handle.Lock.Common

Methods

toException :: FileLockingNotSupported -> SomeException #

fromException :: SomeException -> Maybe FileLockingNotSupported #

displayException :: FileLockingNotSupported -> String #

Exception IOPortException 
Instance details

Defined in GHC.IOPort

Methods

toException :: IOPortException -> SomeException #

fromException :: SomeException -> Maybe IOPortException #

displayException :: IOPortException -> String #

Exception Timeout 
Instance details

Defined in System.Timeout

Methods

toException :: Timeout -> SomeException #

fromException :: SomeException -> Maybe Timeout #

displayException :: Timeout -> String #

Exception SizeOverflowException 
Instance details

Defined in Data.ByteString.Internal.Type

Methods

toException :: SizeOverflowException -> SomeException #

fromException :: SomeException -> Maybe SizeOverflowException #

displayException :: SizeOverflowException -> String #

Exception IOEnvFailure Source # 
Instance details

Defined in GHC.Data.IOEnv

Exception SourceError Source # 
Instance details

Defined in GHC.Types.SourceError

Exception GhcException Source # 
Instance details

Defined in GHC.Utils.Panic

Exception PlainGhcException Source # 
Instance details

Defined in GHC.Utils.Panic.Plain

Exception ParseError 
Instance details

Defined in Text.Parsec.Error

Methods

toException :: ParseError -> SomeException #

fromException :: SomeException -> Maybe ParseError #

displayException :: ParseError -> String #

showException :: Exception e => e -> String Source #

Show an exception as a string.

safeShowException :: Exception e => e -> IO String Source #

Show an exception which can possibly throw other exceptions. Used when displaying exception thrown within TH code.

try :: Exception e => IO a -> IO (Either e a) #

tryMost :: IO a -> IO (Either SomeException a) Source #

Like try, but pass through UserInterrupt and Panic exceptions. Used when we want soft failures when reading interface files, for example. TODO: I'm not entirely sure if this is catching what we really want to catch

throwTo :: Exception e => ThreadId -> e -> IO () #

withSignalHandlers :: ExceptionMonad m => m a -> m a Source #

Temporarily install standard signal handlers for catching ^C, which just throw an exception in the current thread.