Sentinel defines sentinel errors in the root sentinel package. All errors are created with errors.New and can be checked with errors.Is.
Store errors01
| Error | Description |
ErrNoStore | No store was configured on the engine |
ErrStoreClosed | The store has been closed |
ErrMigrationFailed | Database migration failed |
Not-found errors02
| Error | Description |
ErrSuiteNotFound | Suite with the given ID does not exist |
ErrCaseNotFound | Case with the given ID does not exist |
ErrRunNotFound | Run with the given ID does not exist |
ErrBaselineNotFound | Baseline with the given ID does not exist |
ErrPromptVersionNotFound | Prompt version with the given ID does not exist |
Conflict errors03
| Error | Description |
ErrSuiteAlreadyExists | A suite with the same name already exists in this app |
State errors04
| Error | Description |
ErrInvalidState | Invalid state transition |
ErrEmptyInput | Empty input provided |
Evaluation errors05
| Error | Description |
ErrNoTarget | No target configured for the evaluation |
ErrNoScorers | No scorers configured for the case |
Error wrapping06
Store implementations wrap these sentinel errors with additional context:
return fmt.Errorf("postgres: get suite %s: %w", suiteID, sentinel.ErrSuiteNotFound)
Check errors using errors.Is:
s, err := eng.GetSuite(ctx, suiteID)
if errors.Is(err, sentinel.ErrSuiteNotFound) {
// handle not found
}
API error mapping07
The HTTP API maps sentinel errors to HTTP status codes:
| Sentinel error | HTTP status |
ErrSuiteNotFound, ErrCaseNotFound, etc. | 404 Not Found |
ErrSuiteAlreadyExists | 409 Conflict |
ErrInvalidState, ErrEmptyInput | 400 Bad Request |
ErrNoStore | 500 Internal Server Error |