-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
307: Improve error handling, rescue EPIPE and Net::* errors r=brunoocasali a=brunoocasali # Pull Request This PR fixes a bad DX when comes to errors, if a user tries to upload a big dataset, they will face some errors, one of them was related to the `Errno::EPIPE` error, which is really hard to figure out. The idea of this PR is to handle the errors and improve the user experience. ## What does this PR do? Fixes #305 ## PR checklist Please check if your PR fulfills the following requirements: - [x] Does this PR fix an existing issue? - [x] Have you read the contributing guidelines? - [x] Have you made sure that the title is accurate and descriptive of the changes? Thank you so much for contributing to Meilisearch! - [ ] Try something with other lib, which address the pipes error better like: httprb/http#473 Co-authored-by: Bruno Casali <[email protected]>
- Loading branch information
Showing
4 changed files
with
31 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe 'MeiliSearch::Client - Errors' do | ||
context 'when request takes to long to answer' do | ||
it 'raises MeiliSearch::TimeoutError' do | ||
timed_client = MeiliSearch::Client.new(URL, MASTER_KEY, { timeout: 0.000001 }) | ||
|
||
expect do | ||
timed_client.version | ||
end.to raise_error(MeiliSearch::TimeoutError) | ||
end | ||
end | ||
|
||
context 'when body is too large' do | ||
let(:index) { client.index('movies') } | ||
|
||
it 'raises MeiliSearch::CommunicationError' do | ||
allow(index.class).to receive(:post).and_raise(Errno::EPIPE) | ||
|
||
expect do | ||
index.add_documents([{ id: 1, text: 'my_text' }]) | ||
end.to raise_error(MeiliSearch::CommunicationError) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters