-
Notifications
You must be signed in to change notification settings - Fork 14
Error naming in MeiliSearch #8
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
Comments
Hi! Love your issue and your investigation 🙂 MeiliSearch sends back a 4xx or a 5xxI like MeiliSearch sends nothing back, problem with communicationI do not like I suggest MeiliSearch SDK raises an errorI would rather use |
I like the Idea. But in the same line as with other issues/features, we might try to define some basic standards. Each SDK will try to handle this in its own way (and it is clearly the case now), but it could be cool to have a generic 'reference' for errors, codes and messages, and implement THAT in each SDK in it's own way and with its own constraints! |
Yes, we want to define generic rules for error handling, that's the purpose of Charlotte's issue: the first step toward these generic rules ;) We should definitely take the time to define what are the minimum errors we expect in each SDK and the behavior they should have. The three ones that Charlotte suggests is a good start. |
Closing this issue in favor of #19 |
Uh oh!
There was an error while loading. Please reload this page.
Foreword
MeiliSearch is an API with which you communicate through HTTP requests.
Because of that, it uses the HTTP error standards to inform you of the state of each request.
A wrapper, on the other hand, creates a sweet sugar coat around the API to make the communication easier in a given language. Although the wrapper uses HTTP requests, the user does not.
This is why I questioned to which extends do we want to communicate to the user the same way the API communicates with us: through HTTP error codes.
Problem
Imagine a case where you have badly formatted a search parameter the following way:
If javascript validates data before sending it to MeiliSearch, it will raise an error like this (the text could be different):
MeiliSearchError: invalid query parameter
If javascript DOES NOT validate data before sending it to MeiliSearch, MeiliSearch API will send this back
And could be formatted this way by javascript error handler:
This create an inconsistency in the error types.
Examples
How does the other API does it:
example of stripeAPIError

This error will natively output like this:
ApiError
Used in those cases :

Which means that the error output will natively look like this:
So no mention of Algolia (but you will be able to see that it comes from algolia in the stack that appears below the error), and the status can be fetch this way:
e.status
Proposition
MeiliSearch sends back a 4xx or a 5xx
My favorite approach is the one from Stripe. Nevertheless, in a short term I would suggest this one:
or
MeiliSearch sends nothing back, problem with communication
MeiliSearch SDK raises an error
or
The text was updated successfully, but these errors were encountered: