package code

type Scope uint32    // SS (00..99)
type Category uint32 // CCC (000..999)
type Detail uint32   // DDD (000..999) // Updated to 3 digits

const (
	Unset              Scope  = 0
	CategoryMultiplier uint32 = 1000
	ScopeMultiplier    uint32 = 1000000
	NonCode            uint32 = 0
	OK                 uint32 = 0 // Already exists, but merged for completeness; avoid duplication if needed
	SUCCESSCode               = "00000000"
	SUCCESSMessage            = "success"
)

// Boundary constants for validation
const (
	MaxCategory Category = 999 // Maximum allowed category value
	MaxDetail   Detail   = 999 // Maximum allowed detail value (updated)

	DefaultCategory Category = 0
	DefaultDetail   Detail   = 0

	// Reserved values - DO NOT USE in normal operations
	// These are used internally for overflow protection

	ReservedMaxCategory Category = 999 // Used when category > 999
	ReservedMaxDetail   Detail   = 999 // Used when detail > 999 (updated)
)

// New 3-digit categories (merged from original category + detail)
// Input errors (100-109)
const (
	InputInvalidFormat          Category = 101
	InputNotValidImplementation Category = 102
	InputInvalidRange           Category = 103
)

// DB errors (200-209)
const (
	DBError       Category = 201
	DBDataConvert Category = 202
	DBDuplicate   Category = 203
)

// Resource errors (300-399)
const (
	ResNotFound          Category = 301
	ResInvalidFormat     Category = 302
	ResAlreadyExist      Category = 303
	ResInsufficient      Category = 304
	ResInsufficientPerm  Category = 305
	ResInvalidMeasureID  Category = 306
	ResExpired           Category = 307
	ResMigrated          Category = 308
	ResInvalidState      Category = 309
	ResInsufficientQuota Category = 310
	ResMultiOwner        Category = 311
)

// GRPC category

const (
	CatGRPC Category = 400
)

// Auth errors (500-509)
const (
	AuthUnauthorized       Category = 501
	AuthExpired            Category = 502
	AuthInvalidPosixTime   Category = 503
	AuthSigPayloadMismatch Category = 504
	AuthForbidden          Category = 505
)

// System errors (600-609)
const (
	SysInternal       Category = 601
	SysMaintain       Category = 602
	SysTimeout        Category = 603
	SysTooManyRequest Category = 604
)

// PubSub errors (700-709)
const (
	PSuPublish  Category = 701
	PSuConsume  Category = 702
	PSuTooLarge Category = 703
)

// Service errors (800-809)
const (
	SvcInternal    Category = 801
	SvcThirdParty  Category = 802
	SvcHTTP400     Category = 803
	SvcMaintenance Category = 804
)

const (
	Gateway Scope = 10
)
