|
1 |
| -//! Errors |
2 |
| -
|
3 |
| -use crate::id::TwitchTokenErrorResponse; |
4 |
| -use oauth2::HttpResponse as OAuth2HttpResponse; |
5 |
| -use oauth2::RequestTokenError; |
6 |
| -/// General errors for talking with twitch, currently only used in [AppAccessToken::get_app_access_token][crate::tokens::AppAccessToken::get_app_access_token] |
7 |
| -#[allow(missing_docs)] |
8 |
| -#[derive(thiserror::Error, Debug, displaydoc::Display)] |
9 |
| -pub enum TokenError<RE: std::error::Error + Send + Sync + 'static> { |
10 |
| - /// request for token failed. {0} |
11 |
| - Request(RequestTokenError<RE, TwitchTokenErrorResponse>), |
12 |
| - /// could not parse url |
13 |
| - ParseError(#[from] oauth2::url::ParseError), |
14 |
| - /// could not get validation for token |
15 |
| - ValidationError(#[from] ValidationError<RE>), |
16 |
| -} |
17 |
| - |
18 |
| -/// Errors for [validate_token][crate::validate_token] |
19 |
| -#[derive(thiserror::Error, Debug, displaydoc::Display)] |
20 |
| -pub enum ValidationError<RE: std::error::Error + Send + Sync + 'static> { |
21 |
| - /// deserializations failed |
22 |
| - DeserializeError(#[from] serde_json::Error), |
23 |
| - /// token is not authorized for use |
24 |
| - NotAuthorized, |
25 |
| - /// twitch returned an unexpected status: {0} |
26 |
| - TwitchError(TwitchTokenErrorResponse), |
27 |
| - /// failed to request validation: {0} |
28 |
| - Request(#[source] RE), |
29 |
| -} |
30 |
| - |
31 |
| -/// Errors for [revoke_token][crate::revoke_token] |
32 |
| -#[allow(missing_docs)] |
33 |
| -#[derive(thiserror::Error, Debug, displaydoc::Display)] |
34 |
| -pub enum RevokeTokenError<RE: std::error::Error + Send + Sync + 'static> { |
35 |
| - /// 400 Bad Request: {0} |
36 |
| - BadRequest(String), |
37 |
| - /// failed to do revokation: {0} |
38 |
| - RequestError(#[source] RE), |
39 |
| - /// got unexpected return: {0:?} |
40 |
| - Other(OAuth2HttpResponse), |
41 |
| -} |
42 |
| - |
43 |
| -/// Errors for [TwitchToken::refresh_token][crate::TwitchToken::refresh_token] |
44 |
| -#[allow(missing_docs)] |
45 |
| -#[derive(thiserror::Error, Debug, displaydoc::Display)] |
46 |
| -pub enum RefreshTokenError<RE: std::error::Error + Send + Sync + 'static> { |
47 |
| - /// request for token failed. {0} |
48 |
| - RequestError(#[source] RequestTokenError<RE, TwitchTokenErrorResponse>), |
49 |
| - /// could not parse url |
50 |
| - ParseError(#[from] oauth2::url::ParseError), |
51 |
| - /// no refresh token found |
52 |
| - NoRefreshToken, |
53 |
| -} |
| 1 | +//! Errors |
| 2 | +
|
| 3 | +use crate::id::TwitchTokenErrorResponse; |
| 4 | +use oauth2::HttpResponse as OAuth2HttpResponse; |
| 5 | +use oauth2::RequestTokenError; |
| 6 | +/// General errors for talking with twitch, currently only used in [AppAccessToken::get_app_access_token][crate::tokens::AppAccessToken::get_app_access_token] |
| 7 | +#[allow(missing_docs)] |
| 8 | +#[derive(thiserror::Error, Debug, displaydoc::Display)] |
| 9 | +pub enum TokenError<RE: std::error::Error + Send + Sync + 'static> { |
| 10 | + /// request for token failed. {0} |
| 11 | + Request(RequestTokenError<RE, TwitchTokenErrorResponse>), |
| 12 | + /// could not parse url |
| 13 | + ParseError(#[from] oauth2::url::ParseError), |
| 14 | + /// could not get validation for token |
| 15 | + ValidationError(#[from] ValidationError<RE>), |
| 16 | +} |
| 17 | + |
| 18 | +/// Errors for [validate_token][crate::validate_token] |
| 19 | +#[derive(thiserror::Error, Debug, displaydoc::Display)] |
| 20 | +pub enum ValidationError<RE: std::error::Error + Send + Sync + 'static> { |
| 21 | + /// deserializations failed |
| 22 | + DeserializeError(#[from] serde_json::Error), |
| 23 | + /// token is not authorized for use |
| 24 | + NotAuthorized, |
| 25 | + /// twitch returned an unexpected status: {0} |
| 26 | + TwitchError(TwitchTokenErrorResponse), |
| 27 | + /// failed to request validation: {0} |
| 28 | + Request(#[source] RE), |
| 29 | +} |
| 30 | + |
| 31 | +/// Errors for [revoke_token][crate::revoke_token] |
| 32 | +#[allow(missing_docs)] |
| 33 | +#[derive(thiserror::Error, Debug, displaydoc::Display)] |
| 34 | +pub enum RevokeTokenError<RE: std::error::Error + Send + Sync + 'static> { |
| 35 | + /// 400 Bad Request: {0} |
| 36 | + BadRequest(String), |
| 37 | + /// failed to do revokation: {0} |
| 38 | + RequestError(#[source] RE), |
| 39 | + /// got unexpected return: {0:?} |
| 40 | + Other(OAuth2HttpResponse), |
| 41 | +} |
| 42 | + |
| 43 | +/// Errors for [TwitchToken::refresh_token][crate::TwitchToken::refresh_token] |
| 44 | +#[allow(missing_docs)] |
| 45 | +#[derive(thiserror::Error, Debug, displaydoc::Display)] |
| 46 | +pub enum RefreshTokenError<RE: std::error::Error + Send + Sync + 'static> { |
| 47 | + /// request for token failed. {0} |
| 48 | + RequestError(#[source] RequestTokenError<RE, TwitchTokenErrorResponse>), |
| 49 | + /// could not parse url |
| 50 | + ParseError(#[from] oauth2::url::ParseError), |
| 51 | + /// no client secret found |
| 52 | + /// |
| 53 | + /// A client secret is needed to request a refreshed token. |
| 54 | + NoClientSecretFound, |
| 55 | + /// no refresh token found |
| 56 | + NoRefreshToken, |
| 57 | +} |
0 commit comments