-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Normalize known DB errors to a MedusaError when possible #6922
Conversation
🦋 Changeset detectedLatest commit: c1dff52 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
2 Ignored Deployments
|
6a337e8
to
82d369b
Compare
packages/utils/src/dal/mikro-orm/integration-tests/__tests__/mikro-orm-repository.spec.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great addition @sradevski!
return null | ||
} | ||
|
||
return { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we also return the name of the constraint (err.constraint)? I believe adding it to the message in parentheses would be helpful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@carlos-r-l-rodrigues I think that might be too much of an implementation detail that we leak to the FE. What would be nice though is to have it as part of MedusaError in some form and then we plug that into some error logging/tracing before responding to the end user, but I think we can tackle that later when we integrate better with some tracing library
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is the DAL utils, so I expect the backend to have access to these properties.
it is alright to throw from here directly to the front end, but we need to have access to the details on the backend, even to handle errors differently based on the constraint name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@carlos-r-l-rodrigues yeah definitely, whichi s why I think we should add the constraint on MedusaError as a separate field, but not as part of the message. I suggest we just handle that separately though
82d369b
to
00a0d29
Compare
00a0d29
to
bdde2b2
Compare
0ac6593
to
23f1008
Compare
23f1008
to
6bd4bae
Compare
6bd4bae
to
c1dff52
Compare
Before we would swallow the error and return a generic error to the user. This will provide more information to the caller if it is one of the known errors.