gcp_bigquery_client/
error.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
//! List of the BigQuery errors supported by this crate.

use std::collections::HashMap;

use tonic::{metadata::errors::InvalidMetadataValue, Status};

#[allow(clippy::upper_case_acronyms)]
#[derive(thiserror::Error, Debug)]
pub enum BQError {
    #[error("Invalid service account key (error: {0})")]
    InvalidServiceAccountKey(#[from] std::io::Error),

    #[error("Invalid service account authenticator (error: {0})")]
    InvalidServiceAccountAuthenticator(std::io::Error),

    #[error("Invalid installed flow authenticator (error: {0})")]
    InvalidInstalledFlowAuthenticator(std::io::Error),

    #[error("Invalid installed application default credentials authenticator (error: {0})")]
    InvalidApplicationDefaultCredentialsAuthenticator(std::io::Error),

    #[error("Invalid authorized user authenticator (error: {0})")]
    InvalidAuthorizedUserAuthenticator(std::io::Error),

    #[error("Authentication error (error: {0})")]
    AuthError(#[from] yup_oauth2::error::AuthError),

    #[error("Authentication error (error: {0})")]
    YupAuthError(#[from] yup_oauth2::Error),

    #[error("No token")]
    NoToken,

    #[error("Request error (error: {0})")]
    RequestError(#[from] reqwest::Error),

    #[error("Response error (error: {error:?})")]
    ResponseError { error: ResponseError },

    #[error("No data available. The result set is positioned before the first or after the last row. Try to call the method next on your result set.")]
    NoDataAvailable,

    #[error("Invalid column index (col_index: {col_index})")]
    InvalidColumnIndex { col_index: usize },

    #[error("Invalid column name (col_name: {col_name})")]
    InvalidColumnName { col_name: String },

    #[error("Invalid column type (col_index: {col_index}, col_type: {col_type}, type_requested: {type_requested})")]
    InvalidColumnType {
        col_index: usize,
        col_type: String,
        type_requested: String,
    },

    #[error("Json serialization error (error: {0})")]
    SerializationError(#[from] serde_json::Error),

    #[error("Tonic transport error (error: {0}")]
    TonicTransportError(#[from] tonic::transport::Error),

    #[error("Tonic invalid metadata value error (error: {0}")]
    TonicInvalidMetadataValueError(#[from] InvalidMetadataValue),

    #[error("Tonic status error (error: {0}")]
    TonicStatusError(#[from] Status),
}

#[derive(Debug, Deserialize)]
pub struct ResponseError {
    pub error: NestedResponseError,
}

#[derive(Debug, Deserialize)]
pub struct NestedResponseError {
    pub code: i64,
    pub errors: Vec<HashMap<String, String>>,
    pub message: String,
    #[serde(default)]
    pub status: String,
}