ghc-9.12: The GHC API
Safe HaskellNone
LanguageGHC2021

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

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

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

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

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 Timeout Source #

Since: base-4.7.0.0

Instance details

Defined in System.Timeout

Exception SizeOverflowException Source # 
Instance details

Defined in Data.ByteString.Internal.Type

Exception GhcApiError Source # 
Instance details

Defined in GHC

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 Void # 
Instance details

Defined in GHC.Internal.Exception.Type

Exception NestedAtomically # 
Instance details

Defined in GHC.Internal.Control.Exception.Base

Exception NoMatchingContinuationPrompt # 
Instance details

Defined in GHC.Internal.Control.Exception.Base

Exception NoMethodError # 
Instance details

Defined in GHC.Internal.Control.Exception.Base

Exception NonTermination # 
Instance details

Defined in GHC.Internal.Control.Exception.Base

Exception PatternMatchFail # 
Instance details

Defined in GHC.Internal.Control.Exception.Base

Exception RecConError # 
Instance details

Defined in GHC.Internal.Control.Exception.Base

Exception RecSelError # 
Instance details

Defined in GHC.Internal.Control.Exception.Base

Exception RecUpdError # 
Instance details

Defined in GHC.Internal.Control.Exception.Base

Exception TypeError # 
Instance details

Defined in GHC.Internal.Control.Exception.Base

Exception Dynamic # 
Instance details

Defined in GHC.Internal.Data.Dynamic

Exception ErrorCall # 
Instance details

Defined in GHC.Internal.Exception

Exception ArithException # 
Instance details

Defined in GHC.Internal.Exception.Type

Exception SomeException # 
Instance details

Defined in GHC.Internal.Exception.Type

Exception AllocationLimitExceeded # 
Instance details

Defined in GHC.Internal.IO.Exception

Exception ArrayException # 
Instance details

Defined in GHC.Internal.IO.Exception

Exception AssertionFailed # 
Instance details

Defined in GHC.Internal.IO.Exception

Exception AsyncException # 
Instance details

Defined in GHC.Internal.IO.Exception

Exception BlockedIndefinitelyOnMVar # 
Instance details

Defined in GHC.Internal.IO.Exception

Exception BlockedIndefinitelyOnSTM # 
Instance details

Defined in GHC.Internal.IO.Exception

Exception CompactionFailed # 
Instance details

Defined in GHC.Internal.IO.Exception

Exception Deadlock # 
Instance details

Defined in GHC.Internal.IO.Exception

Exception ExitCode # 
Instance details

Defined in GHC.Internal.IO.Exception

Exception FixIOException # 
Instance details

Defined in GHC.Internal.IO.Exception

Exception IOException # 
Instance details

Defined in GHC.Internal.IO.Exception

Exception SomeAsyncException # 
Instance details

Defined in GHC.Internal.IO.Exception

Exception GHCiQException Source # 
Instance details

Defined in GHCi.TH

Exception EncodingException Source # 
Instance details

Defined in System.OsString.Encoding.Internal

Exception a => Exception (ExceptionWithContext a) # 
Instance details

Defined in GHC.Internal.Exception.Type

Exception e => Exception (NoBacktrace e) # 
Instance details

Defined in GHC.Internal.Exception.Type

Methods

toException :: NoBacktrace e -> SomeException #

fromException :: SomeException -> Maybe (NoBacktrace e) #

displayException :: NoBacktrace e -> String #

backtraceDesired :: NoBacktrace e -> Bool #

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.