Skip to content

Commit

Permalink
fix for directus#17817
Browse files Browse the repository at this point in the history
  • Loading branch information
nodeworks committed Mar 16, 2023
1 parent d711aa0 commit 98a7a21
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions api/src/services/graphql/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1703,10 +1703,25 @@ export class GraphQLService {
*/
formatError(error: BaseException | BaseException[]): GraphQLError {
if (Array.isArray(error)) {
error[0].extensions.code = error[0].code;
if (error[0].extensions) {
error[0].extensions.code = error[0].code;
} else {
error[0].extensions = {
code: error.code,
};
}

return new GraphQLError(error[0].message, undefined, undefined, undefined, undefined, error[0]);
}
error.extensions.code = error.code;

if (error.extensions) {
error.extensions.code = error.code;
} else {
error.extensions = {
code: error.code,
};
}

return new GraphQLError(error.message, undefined, undefined, undefined, undefined, error);
}

Expand Down

0 comments on commit 98a7a21

Please sign in to comment.