mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-09-17 13:37:26 +03:00
Explicitly import thiserror::Error
in place (#827)
<!-- The PR description should answer 2 (maybe 3) important questions: --> ### What To stop us being confused between `Error` type and `Error` trait. <!-- What is this PR trying to accomplish (and why, if it's not obvious)? --> <!-- Consider: do we need to add a changelog entry? --> ### How Import `thiserror::Error` explicitly in place. <!-- How is it trying to accomplish it (what are the implementation steps)? --> V3_GIT_ORIGIN_REV_ID: b930480927b2c64537960cfb69f2b2b30921f4fd
This commit is contained in:
parent
7efcb2e4f6
commit
db96e42358
@ -17,7 +17,6 @@ use schemars::JsonSchema;
|
||||
use serde::{de::Error as SerdeDeError, Deserialize, Deserializer, Serialize, Serializer};
|
||||
use serde_json::{json, Value};
|
||||
use std::collections::HashSet;
|
||||
use thiserror::Error;
|
||||
use tracing_util::{ErrorVisibility, SpanVisibility, TraceableError};
|
||||
use url::Url;
|
||||
|
||||
@ -25,7 +24,7 @@ use url::Url;
|
||||
/// in the claims obtained after decoding the JWT.
|
||||
pub(crate) const DEFAULT_HASURA_CLAIMS_NAMESPACE: &str = "claims.jwt.hasura.io";
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum Error {
|
||||
#[error("Error decoding the `Authorization` header - {0}")]
|
||||
ErrorDecodingAuthorizationHeader(jwt::errors::Error),
|
||||
@ -67,7 +66,7 @@ impl TraceableError for Error {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum InternalError {
|
||||
#[error("Error while constructing the JWT decoding key: {0}")]
|
||||
JWTDecodingKeyError(jwt::errors::Error),
|
||||
|
@ -14,10 +14,9 @@ use serde::{de::Error as SerdeDeError, Deserialize, Deserializer, Serialize, Ser
|
||||
use hasura_authn_core as auth_base;
|
||||
use open_dds::session_variables;
|
||||
use schemars::JsonSchema;
|
||||
use thiserror::Error;
|
||||
use tracing_util::{ErrorVisibility, SpanVisibility, TraceableError};
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum Error {
|
||||
#[error("Error in converting the header value corresponding to the {header_name} to a String - {error}")]
|
||||
ErrorInConvertingHeaderValueToString {
|
||||
@ -37,7 +36,7 @@ impl TraceableError for Error {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum InternalError {
|
||||
#[error("Error while making the authentication HTTP request to the webhook - {0}")]
|
||||
ErrorWhileMakingHTTPRequestToTheAuthHook(reqwest::Error),
|
||||
|
@ -14,7 +14,7 @@ use schema::Annotation;
|
||||
|
||||
/// Request errors are raised before execution of root fields begins.
|
||||
/// Ref: <https://spec.graphql.org/October2021/#sec-Errors.Request-errors>
|
||||
#[derive(Error, Debug)]
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum RequestError {
|
||||
#[error("parsing failed: {0}")]
|
||||
ParseFailure(#[from] gql::ast::spanning::Positioned<gql::parser::Error>),
|
||||
@ -131,7 +131,7 @@ impl TraceableError for FieldError {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum FieldInternalError {
|
||||
#[error("ndc_unexpected: {0}")]
|
||||
NDCUnexpected(#[from] NDCUnexpectedError),
|
||||
@ -179,7 +179,7 @@ impl TraceableError for FieldInternalError {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum NDCUnexpectedError {
|
||||
#[error("ndc_client error: {0}")]
|
||||
NDCClientError(ndc_client::Error),
|
||||
@ -222,7 +222,7 @@ impl From<ndc_client::Error> for FieldError {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
#[error("Query usage analytics encoding failed: {0}")]
|
||||
/// Error occurs while generating query usage analytics JSON.
|
||||
/// Wraps JSON encoding error, the only error currently encountered.
|
||||
|
@ -94,7 +94,7 @@ pub enum InternalError {
|
||||
Engine(#[from] InternalEngineError),
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum InternalDeveloperError {
|
||||
#[error("No source data connector specified for field {field_name} of type {type_name}")]
|
||||
NoSourceDataConnector {
|
||||
@ -182,7 +182,7 @@ pub enum InternalDeveloperError {
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum InternalEngineError {
|
||||
#[error("serialization error: {0}")]
|
||||
SerializationError(#[from] json::Error),
|
||||
@ -217,7 +217,7 @@ pub enum InternalEngineError {
|
||||
InternalGeneric { description: String },
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum OperatorMappingError {
|
||||
#[error("could not find operator mapping for column {column_name:} in data connector {data_connector_name}")]
|
||||
MissingEntryForDataConnector {
|
||||
|
@ -11,7 +11,6 @@ mod remote_joins;
|
||||
|
||||
use plan::ExecuteQueryResult;
|
||||
pub use plan::{ndc_expression, process_model_relationship_definition};
|
||||
use thiserror::Error;
|
||||
|
||||
use gql::normalized_ast::Operation;
|
||||
use hasura_authn_core::Session;
|
||||
@ -133,7 +132,7 @@ pub async fn execute_query(
|
||||
.unwrap_or_else(|e| GraphQLResponse::from_error(&e, expose_internal_errors))
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
#[error("{0}")]
|
||||
struct GraphQlParseError(#[from] gql::ast::spanning::Positioned<gql::parser::Error>);
|
||||
|
||||
@ -143,7 +142,7 @@ impl TraceableError for GraphQlParseError {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
#[error("{0}")]
|
||||
struct GraphQlValidationError(#[from] gql::validation::Error);
|
||||
impl TraceableError for GraphQlValidationError {
|
||||
|
@ -12,7 +12,7 @@ use super::{
|
||||
};
|
||||
|
||||
/// Error type for the NDC API client interactions
|
||||
#[derive(Debug, Error)]
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum Error {
|
||||
#[error(
|
||||
"request to connector failed with status code {}: {0}",
|
||||
|
@ -1,6 +1,4 @@
|
||||
use thiserror::Error;
|
||||
|
||||
pub mod v01;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum NdcDowngradeError {}
|
||||
|
@ -1,10 +1,9 @@
|
||||
use open_dds::{relationships::RelationshipName, types::FieldName};
|
||||
use thiserror::Error;
|
||||
use tracing_util::TraceableError;
|
||||
|
||||
use crate::ndc;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum Error {
|
||||
#[error("internal: {0}")]
|
||||
Internal(#[from] InternalError),
|
||||
@ -18,7 +17,7 @@ impl TraceableError for Error {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum InternalError {
|
||||
#[error("Mapping for source column {source_column} already exists in the relationship {relationship_name}")]
|
||||
MappingExistsInRelationship {
|
||||
|
@ -4,11 +4,10 @@ use smol_str::SmolStr;
|
||||
use std::fmt::{self, Display, Formatter, Write};
|
||||
use std::hash::Hash;
|
||||
use std::str::FromStr;
|
||||
use thiserror::Error;
|
||||
// use std::ops::Deref;
|
||||
// use std::borrow::Borrow;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
#[error("{0}")]
|
||||
pub struct InvalidGraphQlName(pub String);
|
||||
|
||||
|
@ -5,9 +5,7 @@ for each namespace from the schema.
|
||||
use std::collections::HashMap;
|
||||
use std::sync::OnceLock;
|
||||
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum Error {
|
||||
#[error("unable to parse introspection query: {0}")]
|
||||
ParseIntrospectionQuery(String),
|
||||
|
@ -11,9 +11,8 @@ use crate::schema::RegisteredTypeName;
|
||||
|
||||
use indexmap::IndexMap;
|
||||
use serde_json as json;
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum Error {
|
||||
#[error("internal introspection error: normalized introspection ast not as expected: {0}")]
|
||||
InternalNormalizationError(normalized::Error),
|
||||
|
@ -2,13 +2,12 @@ use serde::Serialize;
|
||||
use serde_json as json;
|
||||
use serde_with::serde_as;
|
||||
use std::collections::HashMap;
|
||||
use thiserror::Error;
|
||||
|
||||
use crate::ast::common::{self as ast, TypeContainer, TypeName};
|
||||
use crate::schema::{NodeInfo, SchemaContext};
|
||||
use indexmap::IndexMap;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum Error {
|
||||
// TODO: uses 'Debug' trait
|
||||
#[error("expected argument '{argument_name}' not found on field: {field_call_name}, arguments found: {arguments:?}")]
|
||||
|
@ -27,11 +27,9 @@ use open_dds::types::{CustomTypeName, FieldName, OperatorName};
|
||||
use ref_cast::RefCast;
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use thiserror::Error;
|
||||
|
||||
use super::ndc_validation::NDCValidationError;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum ArgumentMappingError {
|
||||
#[error(
|
||||
"the following arguments referenced in argument mappings are unknown: {}",
|
||||
|
@ -13,11 +13,10 @@ use open_dds::{
|
||||
models::ModelName,
|
||||
types::{CustomTypeName, DataConnectorArgumentName, FieldName},
|
||||
};
|
||||
use thiserror::Error;
|
||||
|
||||
use crate::types::subgraph::{Qualified, QualifiedTypeName, QualifiedTypeReference};
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum NDCValidationError {
|
||||
#[error("collection {collection_name} is not defined in data connector {db_name}")]
|
||||
NoSuchCollection {
|
||||
|
@ -1,6 +1,5 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::{BTreeMap, BTreeSet};
|
||||
use thiserror::Error;
|
||||
|
||||
use open_dds::{
|
||||
aggregates::{
|
||||
@ -73,7 +72,7 @@ pub struct AggregateExpressionGraphqlConfig {
|
||||
pub select_output_type_name: ast::TypeName,
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum AggregateExpressionError {
|
||||
#[error("the following aggregate expression is defined more than once: {name}")]
|
||||
DuplicateAggregateExpressionDefinition {
|
||||
|
@ -1,9 +1,8 @@
|
||||
use crate::helpers::ndc_validation::NDCValidationError;
|
||||
use crate::types::subgraph::Qualified;
|
||||
use open_dds::data_connector::DataConnectorName;
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum DataConnectorError {
|
||||
#[error("The data connector {data_connector} uses ndc-spec v0.2.* and is not yet supported")]
|
||||
NdcV02DataConnectorNotSupported {
|
||||
|
@ -1,16 +1,14 @@
|
||||
use thiserror::Error;
|
||||
|
||||
use crate::stages::{apollo, graphql_config};
|
||||
use crate::NDCValidationError;
|
||||
use open_dds::{
|
||||
arguments::ArgumentName,
|
||||
data_connector::{DataConnectorName, DataConnectorObjectType},
|
||||
types::{CustomTypeName, FieldName},
|
||||
};
|
||||
|
||||
use crate::stages::{apollo, graphql_config};
|
||||
use crate::types::subgraph::Qualified;
|
||||
use crate::NDCValidationError;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum ObjectTypesError {
|
||||
#[error("object type {type_name} could not be found")]
|
||||
ObjectTypeNotFound {
|
||||
@ -55,7 +53,7 @@ pub enum ObjectTypesError {
|
||||
ApolloError(#[from] apollo::ApolloError),
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum TypeMappingValidationError {
|
||||
#[error("data connector {data_connector:} referenced in type mappings of type {type_name:} is not found")]
|
||||
UnknownDataConnector {
|
||||
|
@ -1,11 +1,10 @@
|
||||
use crate::helpers::typecheck;
|
||||
use crate::types::error::Error;
|
||||
use open_dds::types::{CustomTypeName, FieldName};
|
||||
use thiserror::Error;
|
||||
|
||||
use crate::types::subgraph::Qualified;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum TypeOutputPermissionError {
|
||||
#[error("unsupported type in output type permissions definition: {type_name:}; only object types are supported")]
|
||||
UnsupportedTypeInOutputPermissions { type_name: CustomTypeName },
|
||||
@ -28,7 +27,7 @@ impl From<TypeOutputPermissionError> for TypePermissionError {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum TypeInputPermissionError {
|
||||
#[error("unsupported type in input type permissions definition: {type_name:}; only object types are supported")]
|
||||
UnsupportedTypeInInputPermissions { type_name: CustomTypeName },
|
||||
@ -55,7 +54,7 @@ impl From<TypeInputPermissionError> for TypePermissionError {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum TypePermissionError {
|
||||
#[error("{0}")]
|
||||
TypeOutputPermissionError(TypeOutputPermissionError),
|
||||
|
@ -1,5 +1,3 @@
|
||||
use thiserror::Error;
|
||||
|
||||
use crate::stages::{
|
||||
aggregates::AggregateExpressionError, apollo, data_connectors, graphql_config, object_types,
|
||||
type_permissions,
|
||||
@ -23,7 +21,7 @@ use crate::helpers::{
|
||||
};
|
||||
|
||||
// TODO: This enum really needs structuring
|
||||
#[derive(Error, Debug)]
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum Error {
|
||||
#[error("the following model is defined more than once: {name:}")]
|
||||
DuplicateModelDefinition { name: Qualified<ModelName> },
|
||||
@ -499,7 +497,7 @@ pub enum Error {
|
||||
ApolloError(#[from] apollo::ApolloError),
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum ModelAggregateExpressionError {
|
||||
#[error("a source must be defined for model {model:} in order to use aggregate expressions")]
|
||||
CannotUseAggregateExpressionsWithoutSource { model: Qualified<ModelName> },
|
||||
@ -558,7 +556,7 @@ impl From<BooleanExpressionError> for Error {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum BooleanExpressionError {
|
||||
#[error("unknown type used in object boolean expression: {type_name:}")]
|
||||
UnknownTypeInObjectBooleanExpressionType {
|
||||
@ -636,7 +634,7 @@ pub enum BooleanExpressionError {
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum RelationshipError {
|
||||
#[error("source field {field_name} in field mapping for relationship {relationship_name} on type {source_type} is unknown.")]
|
||||
UnknownSourceFieldInRelationshipMapping {
|
||||
@ -710,7 +708,7 @@ impl From<RelationshipError> for Error {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum TypePredicateError {
|
||||
#[error("unknown field '{field_name:}' used in predicate for type '{type_name:}'")]
|
||||
UnknownFieldInTypePredicate {
|
||||
@ -786,7 +784,7 @@ impl From<TypePredicateError> for Error {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum TypeError {
|
||||
#[error("expected to find a custom named type in {qualified_type_reference:} but none found")]
|
||||
NoNamedTypeFound {
|
||||
|
@ -10,12 +10,11 @@ use serde::Serialize;
|
||||
use crate::configuration::PrePluginConfig;
|
||||
use hasura_authn_core::Session;
|
||||
use lang_graphql::{ast::common as ast, http::RawRequest};
|
||||
use thiserror::Error;
|
||||
use tracing_util::{
|
||||
set_attribute_on_active_span, ErrorVisibility, SpanVisibility, Traceable, TraceableError,
|
||||
};
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum Error {
|
||||
#[error("Error while making the HTTP request to the pre-execution plugin {0} - {1}")]
|
||||
ErrorWhileMakingHTTPRequestToTheHook(String, reqwest::Error),
|
||||
|
@ -19,9 +19,7 @@ use execute::HttpContext;
|
||||
use futures::TryFutureExt;
|
||||
use tracing_util::{FutureExt, SpanVisibility, TraceableError};
|
||||
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum ExecutionPlanError {
|
||||
#[error("{0}")]
|
||||
NDCDowngradeError(#[from] execute::ndc::migration::NdcDowngradeError),
|
||||
|
Loading…
Reference in New Issue
Block a user