2025-11-26 01:09:42 +00:00
|
|
|
package user
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
|
|
"github.com/google/uuid"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type NotFoundError struct {
|
2025-11-26 01:42:52 +00:00
|
|
|
// 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
|
|
|
|
|
|
2025-11-26 01:42:52 +00:00
|
|
|
// 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
|
|
|
}
|
|
|
|
|
|
2025-11-26 01:42:52 +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)
|
|
|
|
|
}
|
2025-11-26 01:42:52 +00:00
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
}
|