Skip to content
This repository has been archived by the owner on Oct 7, 2020. It is now read-only.

Avoid crash in case of nonsensical hoogle db #1174

Merged
merged 1 commit into from
Apr 19, 2019

Conversation

fendor
Copy link
Collaborator

@fendor fendor commented Apr 15, 2019

Since the hoogle db location can be defined by the user, it may be possible that the database file location is wrong.
If the file does not exist, an error is reported to the user, but if the file exists but it is just not a hoogle db, hoogle plugin crashes, taking hie with it.

This catches the error and wraps into a HoggleError that can be shown to the user, e.g. to tell him that the db is garbage.

Issue related to: #1146.

  • [ ] Actually show an error to the user. Not adressed in this issue.

@fendor fendor requested a review from lorenzo April 15, 2019 18:41
@fendor
Copy link
Collaborator Author

fendor commented Apr 16, 2019

It is actually unclear when to show a message to the user.

The main usage of Hoogle is to lookup a specifc function name, or used for HsImport. All of these use cases are Commands, executed by CodeActions. It is impossible by design to send messages from code actions. However, we could newtype results from Hoogle and unwrap them in LspStdio to show messages to the user.

How should a message be propagated to the user? It is definitely something we want to show to the user, since it is a configuration error.

@lorenzo
Copy link
Collaborator

lorenzo commented Apr 17, 2019

Could we do a initial health check in HIE startup and send messages to the users on the problems we found?

If any fatal problem is found we could then disable the plugin or just let the stuff silently fail.

This would require some sort of callback function in plugins to perform this check

@fendor
Copy link
Collaborator Author

fendor commented Apr 17, 2019

A health check sounds great to me, it would further help to identify problems with plugins on start up. Moreover, to signal the health of hie in general.
It could be a required field in plugin description

@samuelpilz
Copy link
Contributor

I am thinking about this for a long time now and I am in the process of gathering things that could go wrong. However, a lot of components are currently changing dramatically so this has been postponed (hie-bios, cabal-helper-wrapper, hlint-stuff, ...).

In the next week, I will start implementing the first parts of the checking system.

@fendor
Copy link
Collaborator Author

fendor commented Apr 17, 2019

Then the issue of showing the error to the user is deferred and this is ready to merge?

@fendor fendor changed the title WIP: Avoid crash in case of nonsensical hoogle db Avoid crash in case of nonsensical hoogle db Apr 17, 2019
Copy link
Collaborator

@lukel97 lukel97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might want to later send showMessage notifications to the client when this happens, but this looks good

@fendor fendor merged commit 47b5281 into haskell:master Apr 19, 2019
@alanz alanz added this to the 2019-04 milestone May 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants