Loading...
Loading...
Generate custom typed errors. Use when adding or extending module error definitions.
npx skill4agent add cristiano-pacheco/ai-tools go-errorerrsinternal/modules/<module>/errs/errs.gopackage errsnet/httpbrickserrs "github.com/cristiano-pacheco/bricks/pkg/errs"var (...)brickserrs.New("<MODULE>_<NN>", "<message>", http.<Status>, nil)package errs
import (
"net/http"
brickserrs "github.com/cristiano-pacheco/bricks/pkg/errs"
)
var (
// ErrProfileValidationFailed is returned when profile validation fails.
ErrProfileValidationFailed = brickserrs.New(
"PROFILE_01",
"profile validation failed",
http.StatusBadRequest,
nil,
)
// ErrProfileNotFound is returned when the profile is not found.
ErrProfileNotFound = brickserrs.New("PROFILE_02", "profile not found", http.StatusNotFound, nil)
)
// NewProfileValidationError returns a structured validation error with field-level details.
func NewProfileValidationError(details []brickserrs.Detail) *brickserrs.Error {
return brickserrs.New(
ErrProfileValidationFailed.Code,
ErrProfileValidationFailed.Message,
ErrProfileValidationFailed.Status,
details,
)
}catalogprofileaiexportErrProfileNotFound"profile not found"http.StatusNotFoundinternal/modules/<module>/errs/errs.goCATALOG_01CATALOG_02CATALOG_09CATALOG_10CATALOG_11var (...)NewXxxValidationError(details []brickserrs.Detail) *brickserrs.Error.Code.Message.Statuserrors.New(...)locales/en.json"errors""PROFILE_02": "Profile not found"locales/pt_BR.jsonErrErrProfileNotFoundErrAIGenerationFailed<MODULE>_<NN>CATALOG_09EXPORT_15AI_07brickserrs.New()locales/en.json"profile not found""invalid prompt type""ai provider unavailable"http.StatusBadRequesthttp.StatusUnauthorizedhttp.StatusForbiddenhttp.StatusNotFoundhttp.StatusConflicthttp.StatusTooManyRequestshttp.StatusBadGatewayhttp.StatusServiceUnavailablehttp.StatusInternalServerErrorinternal/modules/<module>/errs/errs.goErr...brickserrs.New(...)NewXxxValidationError(details []brickserrs.Detail)errs.Err...locales/en.json"errors"locales/pt_BR.jsonmake lintmake nilawayif input.Phone == "" {
return errs.ErrPhoneNumberRequired
}
if profile == nil {
return errs.ErrProfileNotFound
}internal/modules/<module>/errslocales/en.jsonbrickserrs.New()