Elaborate Error Handling in README

pull/5/head
Mingwei Samuel 2020-02-01 17:31:53 -08:00
parent e5489e1c44
commit 266b226602
1 changed files with 31 additions and 13 deletions

View File

@ -84,25 +84,43 @@ Also required for running async integration tests.
### Error Handling ### Error Handling
Riven returns `Result<Option<T>>` within futures. If the `Result` is errored, Riven returns either `Result<T>` or `Result<Option<T>>` within futures.
this indicates that the API request failed to complete successfully, which may be
due to bad user input, Riot server errors, incorrect API key, etc. If the `Option` If the `Result` is errored, this indicates that the API request failed to
is `None`, this indicates that the request completed successfully but no data was complete successfully, which may be due to bad user input, Riot server errors,
returned. This happens if a summoner (by name) or match (by id) doesn't exist. incorrect API key, etc.
If the `Option` is `None`, this indicates that the request completed
successfully but no data was returned. This happens in several situations, such
as getting a summoner (by name) or match (by id) that doesn't exist, or getting
spectator data for a summoner who is not in-game.
Specifically, the API returned a 404 HTTP status code in this situation.
The error type used by Riven is `riven::RiotApiError`. It provides some basic
diagnostic information, such as the source Reqwest error, the number of retries
attempted, and the Reqwest `Response` object.
You can configure the number of time Riven retries using
`RiotApiConfig::set_retries(...)` and the `RiotApi::with_config(config)`
constructor. By default, Riven retries up to 3 times (4 requests total).
Some errors, such as 400 client errors, are not retried as they would
inevitably fail again.
### Semantic Versioning ### Semantic Versioning
This package follows semantic versioning to an extent. However, the Riot API This package follows semantic versioning to an extent. However, the Riot API
itself changes often and does not follow semantic versioning, which makes things itself changes often and does not follow semantic versioning, which makes
difficult. Out-of-date versions will slowly partially cease to work due to this. things difficult. Out-of-date versions will slowly partially cease to work due
to this.
When the API changes, this may result in breaking changes in the `models` module, When the API changes, this may result in breaking changes in the `models`
`endpoints` module, and some of the `consts` module. module, `endpoints` module, and some of the `consts` module. "Handle accessor"
"Handle accessors" may be removed from `RiotApi` if the corresponding endpoint is methods may be removed from `RiotApi` if the corresponding endpoint is removed
removed from the Riot API. from the Riot API. These breaking changes will increment the **MINOR** version,
These changes will increment the **MINOR** version. not the major version.
Parts of Riven that do not depend on Riot API changes do follow semantic versioning. Parts of Riven that do not depend on Riot API changes do follow semantic
versioning.
### Additional Info ### Additional Info