@@ -812,19 +812,23 @@ function completeValueCatchingError(
812
812
if ( isPromise ( completed ) ) {
813
813
// Note: we don't rely on a `catch` method, but we do expect "thenable"
814
814
// to take a second callback for the error case.
815
- return completed . then ( undefined , rawError => {
816
- const error = locatedFieldError ( rawError , fieldNodes , path ) ;
817
- return handleFieldError ( error , returnType , exeContext ) ;
818
- } ) ;
815
+ return completed . then ( undefined , error =>
816
+ handleFieldError ( error , fieldNodes , path , returnType , exeContext ) ,
817
+ ) ;
819
818
}
820
819
return completed ;
821
- } catch ( rawError ) {
822
- const error = locatedFieldError ( rawError , fieldNodes , path ) ;
823
- return handleFieldError ( error , returnType , exeContext ) ;
820
+ } catch ( error ) {
821
+ return handleFieldError ( error , fieldNodes , path , returnType , exeContext ) ;
824
822
}
825
823
}
826
824
827
- function handleFieldError ( error , returnType , exeContext ) {
825
+ function handleFieldError ( rawError , fieldNodes , path , returnType , exeContext ) {
826
+ const error = locatedError (
827
+ asErrorInstance ( rawError ) ,
828
+ fieldNodes ,
829
+ responsePathAsArray ( path ) ,
830
+ ) ;
831
+
828
832
// If the field type is non-nullable, then it is resolved without any
829
833
// protection from errors, however it still properly locates the error.
830
834
if ( isNonNullType ( returnType ) ) {
@@ -837,11 +841,6 @@ function handleFieldError(error, returnType, exeContext) {
837
841
return null;
838
842
}
839
843
840
- function locatedFieldError ( errorValue , fieldNodes , path ) {
841
- const error = asErrorInstance ( errorValue ) ;
842
- return locatedError ( error , fieldNodes , responsePathAsArray ( path ) ) ;
843
- }
844
-
845
844
/**
846
845
* Implements the instructions for completeValue as defined in the
847
846
* "Field entries" section of the spec.
0 commit comments