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

Present errors to user in helpful way #10

Closed
wincent opened this issue Jul 17, 2015 · 1 comment
Closed

Present errors to user in helpful way #10

wincent opened this issue Jul 17, 2015 · 1 comment

Comments

@wincent
Copy link
Owner

wincent commented Jul 17, 2015

(Forking this from #1).

We should catch some common classes of errors and show the user a helpful warning in the quickfix listing.

  • Trying to search in a non-existent directory (ie. :Ack foo bar)
  • Trying to use quotes (ie. :Ack 'foo bar' or :Ack "foo bar")

Both of those are going to produce errors like:

|| ERR: Error stat()ing: bar'
|| ERR: Error opening directory bar': No such file or directory

Another mistake would be the non-space case (:Ack 'foo'). That won't run into a stat error, but it won't find "foo" either (it's looking for single quote followed by "foo" followed by single quote).

The problem with catching stat errors is they'll likely be slightly different from platform to platform, so we need to find the right way to detect them without risking false positives (alas, we don't necessarily get access to the exit status of the underlying process).

As for catching errors for the 'foo' case, we can probably just consider it an error whenever a search is wrapped in quotes and doesn't return any results.

@wincent
Copy link
Owner Author

wincent commented Jul 22, 2015

Merged #14 into this as it's another class of the same underlying issue.

wincent added a commit that referenced this issue Jul 24, 2015
This is the first step in better error message support.

At the moment we show a "no results" error when there are no results
(fixes #14), and for other
errors (ie. when every line in the result is "invalid", which basically
means that the command failed), we show the error text (partial fix for
#10).

Note that actually getting messages to stay on screen is non-trivial in
Vim (see inline comments), so we end up using `input()` to force things.
It seems to be the only way that reliably works across the board (with
and without vim-dispatch).

Still to do: smart heuristics to provide better messages when people
make common mistakes, like misguidedly trying to wrap their search
pattern in quotes.
wincent added a commit that referenced this issue Jul 24, 2015
Help users see the errors of their ways:

- searching for '"foo"' or "'foo'" will tend not to find what you're
  looking for, unless you literally meant "look for the string 'foo',
  surround by quotes"
- searching for '"foo bar"' is not the right way to deal with spaces;
  show a hint and link to the docs

Note that we also show the failed search pattern, which may be useful
for catching other classes of errors.

Fixes: #10
@wincent wincent closed this as completed Jul 24, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant