@@ -41,52 +41,6 @@ pub struct LazyPlanContext<SN, AP> {
4141 pub affected_path : AP ,
4242}
4343
44- /// An extension trait for `Result` types that can be converted into a `PlanExecutionError`.
45- ///
46- /// This trait provides a lazy, performant way to add contextual information to
47- /// an error, only performing work (like cloning strings) if the `Result` is an `Err`.
48- pub trait IntoPlanExecutionError < T > {
49- fn with_plan_context < SN , AP > (
50- self ,
51- context : LazyPlanContext < SN , AP > ,
52- ) -> Result < T , PlanExecutionError >
53- where
54- SN : FnOnce ( ) -> Option < String > ,
55- AP : FnOnce ( ) -> Option < String > ;
56- }
57-
58- impl < T > IntoPlanExecutionError < T > for Result < T , ProjectionError > {
59- fn with_plan_context < SN , AP > (
60- self ,
61- context : LazyPlanContext < SN , AP > ,
62- ) -> Result < T , PlanExecutionError >
63- where
64- SN : FnOnce ( ) -> Option < String > ,
65- AP : FnOnce ( ) -> Option < String > ,
66- {
67- self . map_err ( |source| {
68- let kind = PlanExecutionErrorKind :: ProjectionFailure ( source) ;
69- PlanExecutionError :: new ( kind, context)
70- } )
71- }
72- }
73-
74- impl < T > IntoPlanExecutionError < T > for Result < T , HeaderRuleRuntimeError > {
75- fn with_plan_context < SN , AP > (
76- self ,
77- context : LazyPlanContext < SN , AP > ,
78- ) -> Result < T , PlanExecutionError >
79- where
80- SN : FnOnce ( ) -> Option < String > ,
81- AP : FnOnce ( ) -> Option < String > ,
82- {
83- self . map_err ( |source| {
84- let kind = PlanExecutionErrorKind :: HeaderPropagation ( source) ;
85- PlanExecutionError :: new ( kind, context)
86- } )
87- }
88- }
89-
9044impl PlanExecutionError {
9145 pub ( crate ) fn new < SN , AP > (
9246 kind : PlanExecutionErrorKind ,
@@ -134,3 +88,49 @@ impl From<PlanExecutionError> for GraphQLError {
13488 }
13589 }
13690}
91+
92+ /// An extension trait for `Result` types that can be converted into a `PlanExecutionError`.
93+ ///
94+ /// This trait provides a lazy, performant way to add contextual information to
95+ /// an error, only performing work (like cloning strings) if the `Result` is an `Err`.
96+ pub trait IntoPlanExecutionError < T > {
97+ fn with_plan_context < SN , AP > (
98+ self ,
99+ context : LazyPlanContext < SN , AP > ,
100+ ) -> Result < T , PlanExecutionError >
101+ where
102+ SN : FnOnce ( ) -> Option < String > ,
103+ AP : FnOnce ( ) -> Option < String > ;
104+ }
105+
106+ impl < T > IntoPlanExecutionError < T > for Result < T , ProjectionError > {
107+ fn with_plan_context < SN , AP > (
108+ self ,
109+ context : LazyPlanContext < SN , AP > ,
110+ ) -> Result < T , PlanExecutionError >
111+ where
112+ SN : FnOnce ( ) -> Option < String > ,
113+ AP : FnOnce ( ) -> Option < String > ,
114+ {
115+ self . map_err ( |source| {
116+ let kind = PlanExecutionErrorKind :: ProjectionFailure ( source) ;
117+ PlanExecutionError :: new ( kind, context)
118+ } )
119+ }
120+ }
121+
122+ impl < T > IntoPlanExecutionError < T > for Result < T , HeaderRuleRuntimeError > {
123+ fn with_plan_context < SN , AP > (
124+ self ,
125+ context : LazyPlanContext < SN , AP > ,
126+ ) -> Result < T , PlanExecutionError >
127+ where
128+ SN : FnOnce ( ) -> Option < String > ,
129+ AP : FnOnce ( ) -> Option < String > ,
130+ {
131+ self . map_err ( |source| {
132+ let kind = PlanExecutionErrorKind :: HeaderPropagation ( source) ;
133+ PlanExecutionError :: new ( kind, context)
134+ } )
135+ }
136+ }
0 commit comments