@@ -4,8 +4,11 @@ use thiserror::Error;
4
4
#[ derive( Error , Debug ) ]
5
5
pub enum RoverClientError {
6
6
/// The provided GraphQL was invalid.
7
- #[ error( "encountered a GraphQL error, registry responded with: {msg}" ) ]
8
- GraphQL { msg : String } ,
7
+ #[ error( "GraphQL error:\n {msg}" ) ]
8
+ GraphQL {
9
+ /// The encountered GraphQL error.
10
+ msg : String ,
11
+ } ,
9
12
10
13
/// Tried to build a [HeaderMap] with an invalid header name.
11
14
#[ error( "invalid header name" ) ]
@@ -20,37 +23,53 @@ pub enum RoverClientError {
20
23
InvalidJSON ( #[ from] serde_json:: Error ) ,
21
24
22
25
/// Encountered an error handling the received response.
23
- #[ error( "encountered an error handling the response: {msg}" ) ]
24
- HandleResponse {
26
+ #[ error( "{msg}" ) ]
27
+ AdhocError {
25
28
/// The error message.
26
29
msg : String ,
27
30
} ,
28
31
32
+ /// The user provided an invalid subgraph name.
33
+ #[ error( "Could not find subgraph \" {invalid_subgraph}\" ." ) ]
34
+ NoSubgraphInGraph {
35
+ /// The invalid subgraph name
36
+ invalid_subgraph : String ,
37
+
38
+ /// A list of valid subgraph names
39
+ // this is not used in the error message, but can be accessed
40
+ // by application-level error handlers
41
+ valid_subgraphs : Vec < String > ,
42
+ } ,
43
+
44
+ /// The Studio API could not find a variant for a graph
45
+ #[ error(
46
+ "The graph registry does not contain variant \" {invalid_variant}\" for graph \" {graph}\" "
47
+ ) ]
48
+ NoSchemaForVariant {
49
+ /// The name of the graph.
50
+ graph : String ,
51
+
52
+ /// The non-existent variant.
53
+ invalid_variant : String ,
54
+ } ,
55
+
29
56
/// Encountered an error sending the request.
30
57
#[ error( "encountered an error while sending a request" ) ]
31
58
SendRequest ( #[ from] reqwest:: Error ) ,
32
59
33
- /// This error occurs when there are no `body.errors` but `body.data` is
34
- /// also empty. In proper GraphQL responses, there should _always_ be either
35
- /// body.errors or body.data
36
- #[ error( "The response from the server was malformed. There was no data found in the reponse body. This is likely an error in GraphQL execution" ) ]
37
- NoData ,
38
-
39
60
/// when someone provides a bad graph/variant combination or isn't
40
61
/// validated properly, we don't know which reason is at fault for data.service
41
62
/// being empty, so this error tells them to check both.
42
- #[ error( "No graph found. Either the graph@variant combination wasn't found or your API key is invalid. " ) ]
43
- NoService ,
63
+ #[ error( "Could not find graph with name \" {graph} \" " ) ]
64
+ NoService { graph : String } ,
44
65
45
- /// This error occurs when the Studio API returns no composition errors AND
46
- /// no check result. This response shouldn't be possible!
47
- #[ error(
48
- "The response from the server was malformed, there was no data from the check operation."
49
- ) ]
50
- NoCheckData ,
66
+ /// This error occurs when the Studio API returns no implementing services for a graph
67
+ /// This response shouldn't be possible!
68
+ #[ error( "The response from Apollo Studio was malformed." ) ]
69
+ MalformedResponse ,
51
70
52
- #[ error( "The graph `{graph_name }` is a non-federated graph. This operation is only possible for federated graphs" ) ]
53
- ExpectedFederatedGraph { graph_name : String } ,
71
+ #[ error( "The graph `{graph }` is a non-federated graph. This operation is only possible for federated graphs" ) ]
72
+ ExpectedFederatedGraph { graph : String } ,
54
73
55
74
/// The API returned an invalid ChangeSeverity value
56
75
#[ error( "Invalid ChangeSeverity." ) ]
0 commit comments