Example #1
0
// GetDbErrors creates MultiError on error from DB.
func GetDbErrors(db *gorm.DB) error {
	errors := db.GetErrors()
	if errors == nil {
		if db.Error != nil {
			return DbToHttpError(db.Error)
		}
		return nil
	}
	// If errors array is present, it already includes the db.Error value,
	// so we do not need to include it.
	specificErrors := make([]error, len(errors))
	for i, err := range errors {
		specificErrors[i] = DbToHttpError(err)
	}
	return MakeMultiError(specificErrors)
}