package enforcer // ApplicationError represents a custom error type as an integer value. type ApplicationError int // GetHTTPStatus extracts the HTTP status code from an ApplicationError. func (a ApplicationError) GetHTTPStatus() int { return int(a) / 1_000_000 } // GetCode returns the integer code associated with the ApplicationError. func (a ApplicationError) GetCode() int { return int(a) } // GetMessage returns the message associated with the ApplicationError. func (a ApplicationError) GetMessage() string { return applicationCodeMap[a] } // applicationCodeMap maps ApplicationError values to their corresponding messages. var applicationCodeMap = make(map[ApplicationError]string) // RegisterError maps an ApplicationError code to its corresponding message. func RegisterError(code ApplicationError, message string) { applicationCodeMap[code] = message } // RegisterErrorMap registers a mapping of ApplicationErrors to their messages. func RegisterErrorMap(errors map[ApplicationError]string) { for code, message := range errors { applicationCodeMap[code] = message } }