Skip to main content

Error Codes

All API errors follow the standard error envelope. This page lists every error code defined in GospeLib.

Error codes are maintained in a single source of truth: data/error-catalog.yaml. Running pnpm codegen:errors regenerates all per-language error files from this catalog.

Error Reference

HTTP StatusError CodeDefault MessageGo VariablePython Exception
404PASSAGE_NOT_FOUNDPassage not foundErrPassageNotFoundPassageNotFoundError
404CHAPTER_NOT_FOUNDChapter not foundErrChapterNotFoundChapterNotFoundError
404BOOK_NOT_FOUNDBook not foundErrBookNotFoundBookNotFoundError
404TOPIC_NOT_FOUNDTopic not foundErrTopicNotFoundTopicNotFoundError
404LEXICON_ENTRY_NOT_FOUNDLexicon entry not foundErrLexiconEntryNotFoundLexiconEntryNotFoundError
400INVALID_REQUESTInvalid requestErrInvalidRequestInvalidRequestError
422VALIDATION_ERRORValidation errorErrValidationErrorGospeLibValidationError
401UNAUTHORIZEDUnauthorizedErrUnauthorizedUnauthorizedError
403FORBIDDENForbiddenErrForbiddenForbiddenError
429RATE_LIMITEDRate limit exceededErrRateLimitedRateLimitedError
500INTERNAL_ERRORInternal server errorErrInternalErrorInternalError
503SERVICE_UNAVAILABLEService unavailableErrServiceUnavailableServiceUnavailableError
502UPSTREAM_UNAVAILABLEThe upstream service is temporarily unavailableErrUpstreamUnavailableUpstreamUnavailableError
501NOT_IMPLEMENTEDNot implementedErrNotImplementedFeatureNotImplementedError

Error Response Format

Every error response includes the error code, a human-readable message, and the request ID for log correlation:

{
"error": {
"code": "PASSAGE_NOT_FOUND",
"message": "Passage not found",
"request_id": "550e8400-e29b-41d4-a716-446655440000"
}
}

The request_id matches the X-Request-ID response header. Include it in support requests and bug reports.

Validation Errors

VALIDATION_ERROR (422) responses include a details field with per-field error information:

{
"error": {
"code": "VALIDATION_ERROR",
"message": "Validation error",
"request_id": "...",
"details": {
"passageId": "Invalid passage ID format. Expected: <bookId>.<chapter>.<verse>"
}
}
}

Language Mappings

Go

Error codes are defined as sentinel variables following the Err + PascalCase pattern:

var ErrPassageNotFound = errors.New("PASSAGE_NOT_FOUND")
var ErrValidationError = errors.New("VALIDATION_ERROR")

Python

Error codes map to exception classes. Custom class names are noted in the table above; all others follow the PascalCase + Error pattern:

raise PassageNotFoundError()
raise GospeLibValidationError(details={"passageId": "..."})

Adding New Error Codes

  1. Add the new entry to data/error-catalog.yaml
  2. Run pnpm codegen:errors to regenerate per-language files
  3. Use the generated sentinel/exception in your service code