Skip to content

--no-time flag seems to change format of exceptions #404

@ezyang

Description

@ezyang

I wrote the following code to handle unwrapping Shake's exceptions thrown by the Shake runner:

-- | When we raise a 'GhcException' or a 'SourceError', try to give
-- @ghc --make@ compatible output (without the extra Shake wrapping.)
-- This is way better for users, since Shake does not print line numbers
-- for SourceErrors.
handleGhcErrors :: IO a -> IO a
handleGhcErrors m =
    handle (\(e :: ShakeException) ->
                -- TODO: there should be a better way of doing this
                case fromException (shakeExceptionInner e) of
                    Just (e' :: GhcException) -> throwIO e'
                    Nothing -> case fromException (shakeExceptionInner e) of
                        Just (e' :: SourceError) -> throwIO e'
                        Nothing -> throwIO e
                ) m

This code only works when --no-time is passed; when it is not passed this code doesn't seem to work. I haven't investigated any further.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions