Skip to content

Rewriting of the error handler #438

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

Merged
merged 8 commits into from
Sep 19, 2022
Merged

Rewriting of the error handler #438

merged 8 commits into from
Sep 19, 2022

Conversation

alallema
Copy link
Contributor

@alallema alallema commented Sep 13, 2022

Pull Request

This PR tries to clean and organize the exceptions by following this guide meilisearch/integration-guides#19

PR checklist

  • Follow the Basic Error Handler rules to normalize Exception
  • Add tests for Exceptions

Notes
The duplication of code on HTTP methods in the MeilisearchHttpResquest and CustomOKHttp files will be treated in a PR linked to the client's refacto

Copy link
Member

@brunoocasali brunoocasali left a comment

Choose a reason for hiding this comment

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

That was an awesome work @alallema 🎉

I just left some comments for you ;)


@Override
public String toString() {
return "APIError: {"
Copy link
Member

Choose a reason for hiding this comment

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

I have some different feelings when I see this haha, but I don't know to improve it :|

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Me neither it was already like this ...

// todo: throw dedicated exception
throw new Exception(e);
} catch (Exception e) {
throw new MeilisearchException(e);
Copy link
Member

Choose a reason for hiding this comment

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

Maybe use a MeilisearchApiException here?

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure about this comment anymore to be honest

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The ApacheHttpClient will be removed so I admit that I didn't spend too much time on it

Copy link
Member

@brunoocasali brunoocasali left a comment

Choose a reason for hiding this comment

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

🎉

@alallema alallema merged commit e63713b into refactor Sep 19, 2022
@alallema alallema deleted the exception branch September 19, 2022 12:14
@alallema alallema linked an issue Sep 26, 2022 that may be closed by this pull request
@alallema alallema linked an issue Oct 13, 2022 that may be closed by this pull request
bors bot added a commit that referenced this pull request Nov 9, 2022
425: Refactorization of the SDK r=alallema a=alallema

Related to this issue: #420

**Done**
- #424
- #427 
- #428
- #432
- #439
- #438 
- #447
- #448
- #449
- #451 
- #450 
- #456
- #473
- #474
- #475
- #476

Co-authored-by: alallema <[email protected]>
Co-authored-by: Amélie <[email protected]>
@alallema alallema added the enhancement New feature or request label Nov 9, 2022
bors bot added a commit that referenced this pull request Nov 14, 2022
488: Update version for the next release (v0.8.0) r=alallema a=alallema

This version includes a major redesign of the SDK. ([#425](#425)) [`@alallema](https://github.com/alallema)`

## ⚠️ Breaking changes

* Redesign of the client (#449) `@alallema:`
    * Use `OkHttp` library by default for the Meilisearch client
    * No interface for the creation of a Client disappearing of the class `GenericServiceTemplate`, `ServiceTemplate`, `AbstractClient`, `ApacheClient`, and `DefaultHttpClient`.
* Rename `getAllIndexes` method in `getIndexes` (#477) `@alallema`
* All parameters of the managers accessible in the client are now private: `Config`, `IndexesHandler`, `InstanceHandler`, ` TasksHandler`, `KeysHandler`, `JsonHandler`.
* Factories for the answer and the response disappeared, those classes were removed: `BasicRequestFactory`, `BasicHttpResponse`, `BasicHttpRequest`, and `MeilisearchHttpRequest`.
* Rewriting of the JsonHandler
    * Offering the possibility to use `Gson`, `Jackson` or create your own handler.([#432]
    * Remove `JsonbJsonHandler`.
* Dump returns a `Task`from v0.28.0 so the `createDump` method has been removed just as the `DumpHandler` class.
* Renaming class `Details` in `TaskDetails`
* All methods return now a `MeilisearchException` instead of a `Exception`.

## 🚀 Enhancements

* Replaced traditional getter setter by ``@Getter`` ``@Setter`` from Lombok library ([#385](#385)) [`@ghousek1](https://github.com/ghousek1)`
* Improve Docker configuration in the package ([#399](#399))
* Add code-coverage tool (jacoco) ([#422](#422)) [`@brunoocasali](https://github.com/brunoocasali)`
* Refactoring:
    * Rewriting of the Error Handler ([#438](#438)) [`@alallema](https://github.com/alallema)`
        * Like the other SDKs, this one now contains `MeilisearchApiError`, `MeiliSearchCommunicationError`, `MeilisearchTimeoutError`, `JsonDecodingException` as well as `JsonEncodingException`.
        * All methods return now a `MeilisearchException` instead of a Exception.
(#432))  [`@alallema](https://github.com/alallema)`
    * Rewrite some missing method (#473) [`@alallema](https://github.com/alallema)`
        * health()
        * isHealthy()
        * getVersion()
        * getStats()
        * index.getStats()
        * updateKey() ([#476](#476)) [`@alallema](https://github.com/alallema)`
    * Add typo tolerance settings ([#371](#371)) [`@alallema](https://github.com/alallema)`
    * Add toString method to SearchRequest Class ([#451](#451)) [`@alallema](https://github.com/alallema)`
    * Add support to PATCH HTTP method ([#472](#472)) [`@alallema](https://github.com/alallema)`


Thanks again to `@alallema,`  `@brunoocasali,`   `@ghousek1,` `@kisaga` ! 🎉


Co-authored-by: alallema <[email protected]>
Co-authored-by: Amélie <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Throw a specific Exception instead of Exception in handlers Timeout Exception
2 participants