Skip to content
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

jinzhu/gorm: Ignore some errors like record not found #805

Closed
moonsub-kim opened this issue Jan 4, 2021 · 2 comments
Closed

jinzhu/gorm: Ignore some errors like record not found #805

moonsub-kim opened this issue Jan 4, 2021 · 2 comments
Labels
proposal more in depth change that requires full team approval

Comments

@moonsub-kim
Copy link
Contributor

moonsub-kim commented Jan 4, 2021

I wish ignore errors especially record not found that is unnecessary to classify as errors in my server.
image
The server queries by request from the client that can manipulate req body, then we always allow record_not_found error.
Most of record_not_found error makes me indifferent to see error rate dashboard.

To Extendability,I suggest adding an option that can ignore some type of errors like below

WithErrorFilter(func(err error) bool{
    if errors.Is(err, gorm.ErrRecordNotFound) {
        return false
    }
    return true
})

If you agree about it, I will make a PR

@knusbaum
Copy link
Contributor

knusbaum commented Jan 4, 2021

@moonsub-kim

This seems like an acceptable option to add. We added something similar to contrib/go-chi/chi recently (#773).
In that one, we ended up calling the option WithStatusCheck, so maybe for consistency we can call this WithErrorCheck

We also just merged contrib/gorm.io/gorm.v1 which is where the next version of gorm moved. We should add the option there too to keep parity between gorm integration versions.

@knusbaum knusbaum added the proposal more in depth change that requires full team approval label Jan 8, 2021
@knusbaum
Copy link
Contributor

Fixed in #806

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposal more in depth change that requires full team approval
Projects
None yet
Development

No branches or pull requests

2 participants