Files
drive/apps/backend/internal/user/err.go

37 lines
813 B
Go
Raw Normal View History

2025-11-26 01:09:42 +00:00
package user
import (
"fmt"
"github.com/google/uuid"
)
type NotFoundError struct {
// ID is the ID that was used to try to find the user.
// Not set if not tried.
2025-11-26 01:09:42 +00:00
id uuid.UUID
// Email is the email that was used to try to find the user.
// Not set if not tried.
email string
2025-11-26 01:09:42 +00:00
}
func newNotFoundError(id uuid.UUID, email string) *NotFoundError {
return &NotFoundError{id, email}
}
2025-11-26 01:09:42 +00:00
func (e *NotFoundError) Error() string {
return fmt.Sprintf("user not found: %v", e.id)
}
type AlreadyExistsError struct {
// Email is the email that was used to try to create the user.
Email string
}
func newAlreadyExistsError(email string) *AlreadyExistsError {
return &AlreadyExistsError{email}
}
func (e *AlreadyExistsError) Error() string {
return fmt.Sprintf("user with email %s already exists", e.Email)
}