if err := s.db.Where(&Category{UUID: id}).First(&category).Error; err != nil {
  if errors.Is(err, gorm.ErrRecordNotFound) {
    return category, models.ErrNoRecordFound
  }
  log.WithError(err).Error("failed to fetch category from database")
  return category, models.ErrDatabaseIssue
}

In the above condition this if block is not executing if errors.Is(err, gorm.ErrRecordNotFound) { and I am getting models.ErrDatabaseIssue in return.

I believe, gorm --> First() function returns gorm.ErrRecordNotFound error if it does not find a matching record.

Expected Behavior Should return models.ErrNoRecordFound in return and if errors.Is(err, gorm.ErrRecordNotFound) should be executed.

Comment From: github-actions[bot]

The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking

Comment From: infected-engineer

closing issues as it was a silly mistake and I was passing models.ErrDatabaseIssue in expectation instead of gorm.ErrRecordNotFound