File tree Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -42,12 +42,14 @@ export interface ExceptionJson {
42
42
stack : string ;
43
43
code : string ;
44
44
codes : ReadonlySet < string > ;
45
+ /** From {@link AggregateError.errors} */
46
+ aggregatees ?: readonly ExceptionJson [ ] ;
45
47
[ key : string ] : unknown ;
46
48
}
47
49
48
50
/**
49
51
* Denote normalization has already happened for this error.
50
- * So the GQL server can know acturately if needs to normalize or not.
52
+ * So the GQL server can know accurately if it needs to normalize or not.
51
53
*/
52
54
export class NormalizedException extends Error {
53
55
constructor ( readonly normalized : ExceptionJson ) {
@@ -132,6 +134,26 @@ export class ExceptionNormalizer {
132
134
} ;
133
135
}
134
136
137
+ if (
138
+ ex instanceof AggregateError &&
139
+ // not subclassed
140
+ ex . name === 'AggregateError'
141
+ ) {
142
+ const aggregatees = ex . errors . map ( ( e ) =>
143
+ this . normalize ( {
144
+ ...params ,
145
+ ex : e ,
146
+ } ) ,
147
+ ) ;
148
+ return {
149
+ aggregatees,
150
+ // shrug?
151
+ codes : [
152
+ aggregatees . every ( ( e ) => e . codes . has ( 'Client' ) ) ? 'Client' : 'Server' ,
153
+ ] ,
154
+ } ;
155
+ }
156
+
135
157
const gqlContext =
136
158
context && context . getType ( ) === 'graphql'
137
159
? GqlExecutionContext . create ( context as any )
You can’t perform that action at this time.
0 commit comments