@@ -813,31 +813,23 @@ function completeValueCatchingError(
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
815
return completed . then ( undefined , rawError => {
816
- const error = locatedError (
817
- asErrorInstance ( rawError ) ,
818
- fieldNodes ,
819
- responsePathAsArray ( path ) ,
820
- ) ;
816
+ const error = locatedFieldError ( rawError , fieldNodes , path ) ;
821
817
822
818
// If the field type is non-nullable, then it is resolved without any
823
819
// protection from errors, however it still properly locates the error.
824
820
if ( isNonNullType ( returnType ) ) {
825
821
throw error ;
826
822
}
827
823
828
- // Otherwise, error protection is applied, logging the error and resolving
829
- // a null value for this field if one is encountered.
824
+ // Otherwise, error protection is applied, logging the error and
825
+ // resolving a null value for this field if one is encountered.
830
826
exeContext . errors . push ( error ) ;
831
827
return null ;
832
828
} ) ;
833
829
}
834
830
return completed ;
835
831
} catch ( rawError ) {
836
- const error = locatedError (
837
- asErrorInstance ( rawError ) ,
838
- fieldNodes ,
839
- responsePathAsArray ( path ) ,
840
- ) ;
832
+ const error = locatedFieldError ( rawError , fieldNodes , path ) ;
841
833
842
834
// If the field type is non-nullable, then it is resolved without any
843
835
// protection from errors, however it still properly locates the error.
@@ -852,6 +844,11 @@ function completeValueCatchingError(
852
844
}
853
845
}
854
846
847
+ function locatedFieldError ( errorValue , fieldNodes , path ) {
848
+ const error = asErrorInstance ( errorValue ) ;
849
+ return locatedError ( error , fieldNodes , responsePathAsArray ( path ) ) ;
850
+ }
851
+
855
852
/**
856
853
* Implements the instructions for completeValue as defined in the
857
854
* "Field entries" section of the spec.
0 commit comments