gcp_bigquery_client/
error.rs1use std::collections::HashMap;
4
5use tonic::{metadata::errors::InvalidMetadataValue, Status};
6
7#[allow(clippy::upper_case_acronyms)]
8#[derive(thiserror::Error, Debug)]
9pub enum BQError {
10 #[error("Invalid service account key (error: {0})")]
11 InvalidServiceAccountKey(#[from] std::io::Error),
12
13 #[error("Invalid service account authenticator (error: {0})")]
14 InvalidServiceAccountAuthenticator(std::io::Error),
15
16 #[error("Invalid installed flow authenticator (error: {0})")]
17 InvalidInstalledFlowAuthenticator(std::io::Error),
18
19 #[error("Invalid installed application default credentials authenticator (error: {0})")]
20 InvalidApplicationDefaultCredentialsAuthenticator(std::io::Error),
21
22 #[error("Invalid authorized user authenticator (error: {0})")]
23 InvalidAuthorizedUserAuthenticator(std::io::Error),
24
25 #[error("Authentication error (error: {0})")]
26 AuthError(#[from] yup_oauth2::error::AuthError),
27
28 #[error("Authentication error (error: {0})")]
29 YupAuthError(#[from] yup_oauth2::Error),
30
31 #[error("No token")]
32 NoToken,
33
34 #[error("Request error (error: {0})")]
35 RequestError(#[from] reqwest::Error),
36
37 #[error("Response error (error: {error:?})")]
38 ResponseError { error: ResponseError },
39
40 #[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.")]
41 NoDataAvailable,
42
43 #[error("Invalid column index (col_index: {col_index})")]
44 InvalidColumnIndex { col_index: usize },
45
46 #[error("Invalid column name (col_name: {col_name})")]
47 InvalidColumnName { col_name: String },
48
49 #[error("Invalid column type (col_index: {col_index}, col_type: {col_type}, type_requested: {type_requested})")]
50 InvalidColumnType {
51 col_index: usize,
52 col_type: String,
53 type_requested: String,
54 },
55
56 #[error("Json serialization error (error: {0})")]
57 SerializationError(#[from] serde_json::Error),
58
59 #[error("Tonic transport error (error: {0}")]
60 TonicTransportError(#[from] tonic::transport::Error),
61
62 #[error("Tonic invalid metadata value error (error: {0}")]
63 TonicInvalidMetadataValueError(#[from] InvalidMetadataValue),
64
65 #[error("Tonic status error (error: {0}")]
66 TonicStatusError(#[from] Status),
67}
68
69#[derive(Debug, Deserialize)]
70pub struct ResponseError {
71 pub error: NestedResponseError,
72}
73
74#[derive(Debug, Deserialize)]
75pub struct NestedResponseError {
76 pub code: i64,
77 pub errors: Vec<HashMap<String, String>>,
78 pub message: String,
79 #[serde(default)]
80 pub status: String,
81}