Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid throwing an error in initializeFlagsWithCradleWithMessage #60

Closed
fendor opened this issue Sep 25, 2019 · 1 comment
Closed

Avoid throwing an error in initializeFlagsWithCradleWithMessage #60

fendor opened this issue Sep 25, 2019 · 1 comment

Comments

@fendor
Copy link
Collaborator

fendor commented Sep 25, 2019

This is mainly for the usage in haskell-ide-engine which dies a horrible death if the cabal file is invalid.

In particular, I would like to change:

initializeFlagsWithCradleWithMessage ::
  GhcMonad m
  => Maybe G.Messager
  -> FilePath -- The file we are loading it because of
  -> Cradle
  -> m ()
initializeFlagsWithCradleWithMessage msg fp cradle = do
    compOpts <- liftIO $ getCompilerOptions fp cradle
    case compOpts of
      Left err -> liftIO $ throwIO err
      Right opts -> initSessionWithMessage msg opts

to

initializeFlagsWithCradleWithMessage ::
  GhcMonad m
  => Maybe G.Messager
  -> FilePath -- The file we are loading it because of
  -> Cradle
  -> m (Maybe CradleError)
initializeFlagsWithCradleWithMessage msg fp cradle = do
    compOpts <- liftIO $ getCompilerOptions fp cradle
    case compOpts of
      Left err -> return $ Just err  
      Right opts -> initSessionWithMessage msg opts >> return Nothing

In the hope that CradleError will be promoted to an even more descriptive error type.

@fendor
Copy link
Collaborator Author

fendor commented Sep 25, 2019

Due to an outdated remote, I totally overlooked the already existing changes! My bad!

@fendor fendor closed this as completed Sep 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant