Safe Haskell | None |
---|---|
Language | GHC2021 |
GHC.Types.SourceError
Description
Source errors
Synopsis
- data SourceError = SourceError SourceErrorContext (Messages GhcMessage)
- mkSrcErr :: SourceErrorContext -> Messages GhcMessage -> SourceError
- srcErrorMessages :: SourceError -> Messages GhcMessage
- throwErrors :: MonadIO io => SourceErrorContext -> Messages GhcMessage -> io a
- throwOneError :: MonadIO io => SourceErrorContext -> MsgEnvelope GhcMessage -> io a
- handleSourceError :: MonadCatch m => (SourceError -> m a) -> m a -> m a
- data SourceErrorContext = SEC !DiagOpts !(DiagnosticOpts GhcMessage)
- getSourceErrorContext :: (Monad m, HasDynFlags m) => m SourceErrorContext
- initSourceErrorContext :: DynFlags -> SourceErrorContext
Documentation
data SourceError Source #
A source error is an error that is caused by one or more errors in the
source code. A SourceError
is thrown by many functions in the
compilation pipeline. Inside GHC these errors are merely printed via
log_action
, but API clients may treat them differently, for example,
insert them into a list box. If you want the default behaviour, use the
idiom:
handleSourceError printExceptionAndWarnings $ do ... api calls that may fail ...
The SourceError
s error messages can be accessed via srcErrorMessages
.
This list may be empty if the compiler failed due to -Werror
(Opt_WarnIsError
).
See printExceptionAndWarnings
for more information on what to take care
of when writing a custom error handler.
Constructors
SourceError SourceErrorContext (Messages GhcMessage) |
Instances
Exception SourceError Source # | |
Defined in GHC.Types.SourceError Methods toException :: SourceError -> SomeException Source # fromException :: SomeException -> Maybe SourceError Source # displayException :: SourceError -> String Source # backtraceDesired :: SourceError -> Bool Source # | |
Show SourceError Source # | |
Defined in GHC.Types.SourceError |
throwErrors :: MonadIO io => SourceErrorContext -> Messages GhcMessage -> io a Source #
throwOneError :: MonadIO io => SourceErrorContext -> MsgEnvelope GhcMessage -> io a Source #
Arguments
:: MonadCatch m | |
=> (SourceError -> m a) | exception handler |
-> m a | action to perform |
-> m a |
Perform the given action and call the exception handler if the action
throws a SourceError
. See SourceError
for more information.
data SourceErrorContext Source #
Constructors
SEC !DiagOpts !(DiagnosticOpts GhcMessage) |
getSourceErrorContext :: (Monad m, HasDynFlags m) => m SourceErrorContext Source #