Skip to content

Commit 5d8bf4d

Browse files
committed
remove redundant error catching
1 parent e3bc90b commit 5d8bf4d

File tree

1 file changed

+6
-17
lines changed

1 file changed

+6
-17
lines changed

src/execution/dispatcher.js

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,12 @@ export class Dispatcher {
1515
this._patches = [];
1616
}
1717

18-
execute(
19-
fn: () => PromiseOrValue<mixed>,
20-
errors: Array<GraphQLError>,
21-
): Promise<mixed> {
22-
try {
23-
const data = fn();
24-
if (isPromise(data)) {
25-
return data.then(undefined, error => {
26-
errors.push(error);
27-
return Promise.resolve(null);
28-
});
29-
}
30-
return Promise.resolve(data);
31-
} catch (error) {
32-
errors.push(error);
33-
return Promise.resolve(null);
18+
execute(fn: () => PromiseOrValue<mixed>): Promise<mixed> {
19+
const data = fn();
20+
if (isPromise(data)) {
21+
return data;
3422
}
23+
return Promise.resolve(data);
3524
}
3625

3726
add(
@@ -41,7 +30,7 @@ export class Dispatcher {
4130
errors: Array<GraphQLError>,
4231
) {
4332
this._patches.push(
44-
this.execute(fn, errors).then(data => ({
33+
this.execute(fn).then(data => ({
4534
value: {
4635
data,
4736
path: pathToArray(path),

0 commit comments

Comments
 (0)