@@ -814,34 +814,27 @@ function completeValueCatchingError(
814
814
// to take a second callback for the error case.
815
815
return completed . then ( undefined , rawError => {
816
816
const error = locatedFieldError ( rawError , fieldNodes , path ) ;
817
-
818
- // If the field type is non-nullable, then it is resolved without any
819
- // protection from errors, however it still properly locates the error.
820
- if ( isNonNullType ( returnType ) ) {
821
- throw error ;
822
- }
823
-
824
- // Otherwise, error protection is applied, logging the error and
825
- // resolving a null value for this field if one is encountered.
826
- exeContext . errors . push ( error ) ;
827
- return null ;
817
+ return handleFieldError ( error , returnType , exeContext ) ;
828
818
} ) ;
829
819
}
830
820
return completed ;
831
821
} catch ( rawError ) {
832
822
const error = locatedFieldError ( rawError , fieldNodes , path ) ;
823
+ return handleFieldError ( error , returnType , exeContext ) ;
824
+ }
825
+ }
833
826
834
- // If the field type is non-nullable, then it is resolved without any
835
- // protection from errors, however it still properly locates the error.
836
- if ( isNonNullType ( returnType ) ) {
837
- throw error ;
838
- }
839
-
840
- // Otherwise, error protection is applied, logging the error and resolving
841
- // a null value for this field if one is encountered.
842
- exeContext . errors . push ( error ) ;
843
- return null ;
827
+ function handleFieldError ( error , returnType , exeContext ) {
828
+ // If the field type is non-nullable, then it is resolved without any
829
+ // protection from errors, however it still properly locates the error.
830
+ if ( isNonNullType ( returnType ) ) {
831
+ throw error ;
844
832
}
833
+
834
+ // Otherwise, error protection is applied, logging the error and resolving
835
+ // a null value for this field if one is encountered.
836
+ exeContext.errors.push(error);
837
+ return null;
845
838
}
846
839
847
840
function locatedFieldError ( errorValue , fieldNodes , path ) {
0 commit comments