package staffing import "errors" // The module has ONE typed error envelope, used across all four endpoints. The service returns these // sentinels (or a ValidationError carrying field messages); the handler maps each to a status and a JSON // body of the shape {"error": {"code", "message", "fields"?}}. var ( // ErrNoDatabase: the service has no database configured (503). ErrNoDatabase = errors.New("staffing: no database configured") // ErrNotFound: the requirement is not a real, open gap in this tenant (404). ErrNotFound = errors.New("staffing: requirement not found or not open") // ErrConflict: a decision landed on a row that was already decided or concurrently superseded (409). ErrConflict = errors.New("staffing: recommendation already decided or superseded") // ErrProblemTooLarge and ErrSolveBudget are defined in optimizer.go and map to 413 and 503. ) // ValidationError carries per field messages for a 422 response (bad parameters: a floor out of range, an // unknown requirement id in an explicit subset). type ValidationError struct { Fields map[string]string } func (e *ValidationError) Error() string { return "staffing: invalid request parameters" } func validationErr(field, msg string) *ValidationError { return &ValidationError{Fields: map[string]string{field: msg}} }