ghc-lib-parser-9.12.2.20250421: The GHC API, decoupled from GHC versions

Safe Haskell | Ignore
Language | GHC2021

GHC.Utils.Panic.Plain

Description

Defines a simple exception type and utilities to throw it. The `PlainGhcException` type is a subset of the `GhcException` type. It omits the exception constructors that involve pretty-printing via `SDoc`.

The reason for this is to avoid import cycles / use of boot files. GHC.Utils.Outputable has many transitive dependencies. To throw exceptions from these modules, the functions here can be used without introducing import cycles.

Synopsis

- data PlainGhcException
  - = PlainSignal Int
  - | PlainUsageError String
  - | PlainCmdLineError String
  - | PlainPanic String
  - | PlainSorry String
  - | PlainInstallationError String
  - | PlainProgramError String
- showPlainGhcException :: PlainGhcException -> ShowS
- panic :: HasCallStack => String -> a
- sorry :: HasCallStack => String -> a
- pgmError :: HasCallStack => String -> a
- cmdLineError :: String -> a
- cmdLineErrorIO :: String -> IO a
- assertPanic :: String -> Int -> a
- assert :: HasCallStack => Bool -> a -> a
- assertM :: (HasCallStack, Monad m) => m Bool -> m ()
- massert :: (HasCallStack, Applicative m) => Bool -> m ()

# Documentation

data PlainGhcException Source #

This type is very similar to `GhcException`, but it omits the constructors that involve pretty-printing via `SDoc`. Due to the implementation of `fromException` for `GhcException`, this type can be caught as a `GhcException`.

Note that this should only be used for throwing exceptions, not for catching, as `GhcException` will not be converted to this type when catching.

Constructors

PlainSignal Int | Some other fatal signal (SIGHUP,SIGTERM)
PlainUsageError String | Prints the short usage msg after the error
PlainCmdLineError String | A problem with the command line arguments, but don't print usage.
PlainPanic String | The `impossible` happened.
PlainSorry String | The user tickled something that's known not to work yet, but we're not counting it as a bug.
PlainInstallationError String | An installation problem.
PlainProgramError String | An error in the user's code, probably.

#### Instances

Instances details

Exception PlainGhcException Source # |
Instance details Defined in GHC.Utils.Panic.Plain Methods toException :: PlainGhcException -> SomeException Source # fromException :: SomeException -> Maybe PlainGhcException Source # displayException :: PlainGhcException -> String Source # backtraceDesired :: PlainGhcException -> Bool Source #
Show PlainGhcException Source # |
Instance details Defined in GHC.Utils.Panic.Plain Methods showsPrec :: Int -> PlainGhcException -> ShowS Source # show :: PlainGhcException -> String Source # showList :: [PlainGhcException] -> ShowS Source #

showPlainGhcException :: PlainGhcException -> ShowS Source #

Append a description of the given exception to this string.

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

Panics and asserts.

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

Panics and asserts.

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

Panics and asserts.

cmdLineError :: String -> a Source #

cmdLineErrorIO :: String -> IO a Source #

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

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

assert :: HasCallStack => Bool -> a -> a Source #

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

massert :: (HasCallStack, Applicative m) => Bool -> m () Source #