@@ -707,16 +707,14 @@ function executeField(
707
707
708
708
result = resolveFn ( source , args , contextValue , info ) ;
709
709
} catch ( rawError ) {
710
- const errors = asyncPayloadRecord ?. errors ?? exeContext . errors ;
711
- const handledError = addError (
710
+ return handleRawError (
712
711
rawError ,
712
+ exeContext ,
713
713
fieldNodes ,
714
714
returnType ,
715
715
path ,
716
- errors ,
716
+ asyncPayloadRecord ,
717
717
) ;
718
- filterSubsequentPayloads ( exeContext , path , asyncPayloadRecord ) ;
719
- return handledError ;
720
718
}
721
719
722
720
if ( isPromise ( result ) ) {
@@ -769,6 +767,20 @@ export function buildResolveInfo(
769
767
} ;
770
768
}
771
769
770
+ function handleRawError (
771
+ rawError : unknown ,
772
+ exeContext : ExecutionContext ,
773
+ fieldNodes : ReadonlyArray < FieldNode > ,
774
+ returnType : GraphQLOutputType ,
775
+ path : Path ,
776
+ asyncPayloadRecord : AsyncPayloadRecord | undefined ,
777
+ ) : null {
778
+ const errors = asyncPayloadRecord ?. errors ?? exeContext . errors ;
779
+ addError ( rawError , fieldNodes , returnType , path , errors ) ;
780
+ filterSubsequentPayloads ( exeContext , path , asyncPayloadRecord ) ;
781
+ return null ;
782
+ }
783
+
772
784
function addError (
773
785
rawError : unknown ,
774
786
fieldNodes : ReadonlyArray < FieldNode > ,
@@ -930,16 +942,14 @@ async function completePromiseCatchingErrors(
930
942
}
931
943
return completed ;
932
944
} catch ( rawError ) {
933
- const errors = asyncPayloadRecord ?. errors ?? exeContext . errors ;
934
- const handledError = addError (
945
+ return handleRawError (
935
946
rawError ,
947
+ exeContext ,
936
948
fieldNodes ,
937
949
returnType ,
938
950
path ,
939
- errors ,
951
+ asyncPayloadRecord ,
940
952
) ;
941
- filterSubsequentPayloads ( exeContext , path , asyncPayloadRecord ) ;
942
- return handledError ;
943
953
}
944
954
}
945
955
@@ -964,16 +974,14 @@ function completeValueCatchingErrors(
964
974
asyncPayloadRecord ,
965
975
) ;
966
976
} catch ( rawError ) {
967
- const errors = asyncPayloadRecord ?. errors ?? exeContext . errors ;
968
- const handledError = addError (
977
+ return handleRawError (
969
978
rawError ,
979
+ exeContext ,
970
980
fieldNodes ,
971
981
returnType ,
972
982
path ,
973
- errors ,
983
+ asyncPayloadRecord ,
974
984
) ;
975
- filterSubsequentPayloads ( exeContext , path , asyncPayloadRecord ) ;
976
- return handledError ;
977
985
}
978
986
979
987
if ( isPromise ( completedValue ) ) {
0 commit comments