types

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 15, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultDateFormat = "2006-01-02 15:04:05"

Variables

View Source
var ErrRecordNotFound = errors.New("record not found")
View Source
var RoleToString = map[Role]string{
	Nil:   "Nil",
	Admin: "Admin",
	User:  "User",
}
View Source
var StringToRole = map[string]Role{
	"Nil":   Nil,
	"Admin": Admin,
	"User":  User,
}

Functions

func ErrIsUserError

func ErrIsUserError(err error) bool

func RoleFromString

func RoleFromString(roleStr string) (string, error)

Types

type AppError added in v1.0.0

type AppError struct {
	Type    ErrorType
	Message string
	Errors  []FieldError // Optional validation errors
}

AppError represents a unified error type with additional context

func NewSystemError added in v1.0.0

func NewSystemError(message string) *AppError

NewSystemError creates an error for internal system failures

func NewUserError added in v1.0.0

func NewUserError(message string) *AppError

NewUserError creates an error that represents a user mistake

func NewValidationError added in v1.0.0

func NewValidationError(message string, errors []FieldError) *AppError

NewValidationError creates an error for request validation failures

func (*AppError) Error added in v1.0.0

func (e *AppError) Error() string

type AppSettings

type AppSettings interface {
	MarshalJSON() ([]byte, error)
	UnmarshalJSON([]byte) error
}

type DatabaseType

type DatabaseType int
const (
	DatabasePostgres DatabaseType = iota
	GoogleCloudsqlPostgres
	DatabaseSqlite
)

type DateTime

type DateTime struct {
	// contains filtered or unexported fields
}

func NowDateTime

func NowDateTime() DateTime

func ParseDateTime

func ParseDateTime(value any) (DateTime, error)

func (DateTime) MarshalJSON

func (d DateTime) MarshalJSON() ([]byte, error)

func (*DateTime) Scan

func (d *DateTime) Scan(value any) error

func (DateTime) String

func (d DateTime) String() string

func (DateTime) Time

func (d DateTime) Time() time.Time

func (*DateTime) UnmarshalJSON

func (d *DateTime) UnmarshalJSON(b []byte) error

func (DateTime) Value

func (d DateTime) Value() (driver.Value, error)

type ErrorType added in v1.0.0

type ErrorType int

ErrorType represents the category of error

const (
	ErrorTypeSystem ErrorType = iota
	ErrorTypeUser
	ErrorTypeValidation
)

type EventClient

type EventClient string
const (
	GcloudPubSubClient   EventClient = "GcloudPubSub"
	AWSEventBridgeClient EventClient = "AWSEventBridgeClient"
	AWSSQSClient         EventClient = "AWSSQSClient"
)

type FieldError

type FieldError struct {
	Field   string `json:"field"`
	Message string `json:"message"`
}

type Role

type Role int
const (
	Nil Role = iota
	Admin
	User
)

func (Role) MarshalJSON

func (r Role) MarshalJSON() ([]byte, error)

MarshalJSON converts the Role to its corresponding string representation for JSON serialization.

func (*Role) UnmarshalJSON

func (r *Role) UnmarshalJSON(data []byte) error

UnmarshalJSON converts a JSON string to the corresponding Role value.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL