Skip to content

Conversation

Khongchai
Copy link

Description

Made MONGODB_ERROR_CODES public

What is the motivation for this change?

We have a use case where accessing the error code definition is useful for error checking. Checking e.code === MONGODB_ERROR_CODES.Something seems pretty useful. The object is already frozen so we can't just accidentally modify this.

This is a small type change so I haven't run any tests / compilation yet. But would be happy to do so if still required! Thanks, mongodb team

@Khongchai Khongchai requested a review from a team as a code owner August 7, 2025 07:51
@durran durran changed the title made MONGODB_ERROR_CODES public feat(NODE-7100): make MONGODB_ERROR_CODES public Aug 7, 2025
@durran durran added tracked-in-jira Ticket filed in MongoDB's Jira system External Submission PR submitted from outside the team labels Aug 7, 2025
@durran
Copy link
Member

durran commented Aug 7, 2025

Hi @Khongchai, thanks for the contribution. We have a ticket tracking this and will discuss in our triage next week.

@baileympearson baileympearson self-assigned this Aug 11, 2025
@baileympearson baileympearson added the Primary Review In Review with primary reviewer, not yet ready for team's eyes label Aug 11, 2025
@marcesengel
Copy link

marcesengel commented Aug 12, 2025

Would be nice if the duplicate key error could be added as well, right now I have a helper function which checks code for the magic number 11_000.

@baileympearson
Copy link
Contributor

Hey @Khongchai , would you mind elaborating a bit on exactly what your use case for this feature would be and exactly what you'd like to see from us if we were to make this enum public? Are you looking for a more descriptive name for a particular error or maybe looking to understand what a particular error means? As @marcesengel alludes to, this error enum is not exhaustive (it only contains error codes we use in the driver).

MongoDB's error codes are also officially documented.

@Khongchai
Copy link
Author

@baileympearson I see. I did not look through the entire list thoroughly, thought it was exhaustive. Our use case is the same as @marcesengel. We also check against error code 26.

Considering that it's just something you created to use internally and it's not exhaustive, I'll just close this PR. Thanks, everyone!

@Khongchai Khongchai closed this Aug 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

External Submission PR submitted from outside the team Primary Review In Review with primary reviewer, not yet ready for team's eyes tracked-in-jira Ticket filed in MongoDB's Jira system

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants