Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Let the caller decide what kind of error they want to returns when parsing AscDesc #342

Merged
merged 1 commit into from
Sep 8, 2021

Conversation

irevoire
Copy link
Member

@irevoire irevoire commented Sep 7, 2021

This is one possible fix for #339
We would then need to patch these lines https://github.com/meilisearch/MeiliSearch/blob/main/meilisearch-http/src/index/search.rs#L110-L114 to return the error we want.

Another solution would be to add a parameter to the from_str to specify which context we are in.

@irevoire irevoire requested a review from Kerollmops September 7, 2021 09:46
Copy link
Member

@Kerollmops Kerollmops left a comment

Choose a reason for hiding this comment

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

I am not sure it is the best solution, couldn't we introduce a new struct unit error instead, just for the AscDesc syntax? i.e. struct InvalidAscDescSyntax. We can then just do a text.to_string() on the caller side?

@irevoire
Copy link
Member Author

irevoire commented Sep 7, 2021

How is a to_string going to solve our issue?
Do you mean something like a to_criterion_error and to_sort_error?

@Kerollmops
Copy link
Member

No, What I want is to create a custom error specific to this error instead of returning a String in the Err variant. Then when an error is found i.e. Err(InvalidAscDescSyntax) we can simply create the error message like before i.e UserError::InvalidCriterionName or any other error. I don't like the fact that we return a text.to_string() in the error variant, it doesn't mean anything and is useless as we already have the text on the caller side.

@irevoire
Copy link
Member Author

irevoire commented Sep 7, 2021

Ah ok I get the idea thanks!
I'll do it tomorrow morning

@irevoire irevoire force-pushed the error/sort branch 2 times, most recently from ebf4a07 to fa3729f Compare September 8, 2021 08:41
@irevoire irevoire requested a review from Kerollmops September 8, 2021 08:45
milli/src/error.rs Outdated Show resolved Hide resolved
milli/src/error.rs Outdated Show resolved Hide resolved
milli/src/error.rs Outdated Show resolved Hide resolved
@Kerollmops Kerollmops added the DB breaking The related changes break the DB label Sep 8, 2021
Copy link
Member

@Kerollmops Kerollmops left a comment

Choose a reason for hiding this comment

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

Thank you very much, merging! 🧛
bors merge

@bors
Copy link
Contributor

bors bot commented Sep 8, 2021

@bors bors bot merged commit b22aac9 into main Sep 8, 2021
@bors bors bot deleted the error/sort branch September 8, 2021 14:25
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
DB breaking The related changes break the DB
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants