Skip to content

Commit 0d750da

Browse files
committed
no error prefixes in string
1 parent 45d18e3 commit 0d750da

File tree

5 files changed

+12
-41
lines changed

5 files changed

+12
-41
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,3 @@ perf.txt
1919
query.txt
2020
schema.graphql
2121
target/
22-
bin/installcheck

Cargo.lock

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ base64 = "0.13"
3333
lazy_static = "1"
3434
bimap = { version = "0.6.3", features = ["serde"] }
3535
indexmap = "2.2"
36-
thiserror = "1.0"
36+
thiserror = "2.0"
3737

3838
[dev-dependencies]
3939
pgrx-tests = "=0.12.9"

src/error.rs

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ pub enum GraphQLError {
1010
Parse(String),
1111

1212
/// Field resolution errors
13-
#[error("Field not found: {field} on type {type_name}")]
13+
#[error("Unknown field \"{field}\" on type {type_name}")]
1414
FieldNotFound { field: String, type_name: String },
1515

1616
/// General operation errors with context
17-
#[error("{context}: {message}")]
17+
#[error("{message}")]
1818
Operation { context: String, message: String },
1919
}
2020

@@ -43,11 +43,6 @@ impl From<&str> for GraphQLError {
4343
}
4444

4545
impl GraphQLError {
46-
/// Creates a parse error
47-
pub fn parse(message: impl Into<String>) -> Self {
48-
Self::Parse(message.into())
49-
}
50-
5146
/// Creates a field not found error
5247
pub fn field_not_found(field: impl Into<String>, type_name: impl Into<String>) -> Self {
5348
Self::FieldNotFound {
@@ -104,14 +99,6 @@ impl GraphQLError {
10499
}
105100
}
106101

107-
/// Creates an authorization error
108-
pub fn authorization(message: impl Into<String>) -> Self {
109-
Self::Operation {
110-
context: "Authorization error".to_string(),
111-
message: message.into(),
112-
}
113-
}
114-
115102
/// Creates an internal error
116103
pub fn internal(message: impl Into<String>) -> Self {
117104
Self::Operation {
@@ -120,21 +107,6 @@ impl GraphQLError {
120107
}
121108
}
122109

123-
/// Creates an unsupported operation error
124-
pub fn unsupported_operation(operation: impl Into<String>) -> Self {
125-
Self::Operation {
126-
context: "Operation not supported".to_string(),
127-
message: operation.into(),
128-
}
129-
}
130-
131-
/// Creates a configuration error
132-
pub fn configuration(message: impl Into<String>) -> Self {
133-
Self::Operation {
134-
context: "Configuration error".to_string(),
135-
message: message.into(),
136-
}
137-
}
138110
}
139111

140112
/// Type alias for Results that use GraphQLError

src/transpile.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ pub trait MutationEntrypoint<'conn> {
5151
let sql = match sql {
5252
Ok(sql) => sql,
5353
Err(err) => {
54-
return Err(GraphQLError::sql_generation(format!("Mutation SQL generation error: {}", err)));
54+
return Err(err.clone());
5555
}
5656
};
5757

@@ -84,7 +84,7 @@ pub trait QueryEntrypoint {
8484
let sql = match sql {
8585
Ok(sql) => sql,
8686
Err(err) => {
87-
return Err(GraphQLError::sql_generation(format!("Query SQL generation error: {}", err)));
87+
return Err(err.clone());
8888
}
8989
};
9090

0 commit comments

Comments
 (0)