Error Handling
Sentinel errors returned by evaluation operations.
Sentinel defines sentinel errors in the root sentinel package. All errors are created with errors.New and can be checked with errors.Is.
| Error | Description |
|---|
ErrNoStore | No store was configured on the engine |
ErrStoreClosed | The store has been closed |
ErrMigrationFailed | Database migration failed |
| 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 |
| Error | Description |
|---|
ErrSuiteAlreadyExists | A suite with the same name already exists in this app |
| Error | Description |
|---|
ErrInvalidState | Invalid state transition |
ErrEmptyInput | Empty input provided |
| Error | Description |
|---|
ErrNoTarget | No target configured for the evaluation |
ErrNoScorers | No scorers configured for the case |
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
}
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 |