Skip to content

Commit

Permalink
Use console.error for Prisma errors (#8722)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel Cousens <dcousens@users.noreply.github.com>
  • Loading branch information
dcousens and dcousens committed Aug 13, 2023
1 parent 9b22f96 commit 98fbbeb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/more-errors-please.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@keystone-6/core': minor
---

`KS_PRISMA_ERRORS` are now logged with `console.error` on the server
6 changes: 4 additions & 2 deletions packages/core/src/lib/core/graphql-errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ export const userInputError = (msg: string) =>
export const accessDeniedError = (msg: string) =>
new GraphQLError(`Access denied: ${msg}`, { extensions: { code: 'KS_ACCESS_DENIED' } });

export const prismaError = (err: Error) => {
export function prismaError(err: Error) {
console.error(err);

if ((err as any).code === undefined) {
return new GraphQLError(`Prisma error`, {
extensions: {
Expand All @@ -23,7 +25,7 @@ export const prismaError = (err: Error) => {
prisma: { ...err },
},
});
};
}

export const validationFailureError = (messages: string[]) => {
const s = messages.map(m => ` - ${m}`).join('\n');
Expand Down

0 comments on commit 98fbbeb

Please sign in to comment.