Sentinel

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.

Store errors

ErrorDescription
ErrNoStoreNo store was configured on the engine
ErrStoreClosedThe store has been closed
ErrMigrationFailedDatabase migration failed

Not-found errors

ErrorDescription
ErrSuiteNotFoundSuite with the given ID does not exist
ErrCaseNotFoundCase with the given ID does not exist
ErrRunNotFoundRun with the given ID does not exist
ErrBaselineNotFoundBaseline with the given ID does not exist
ErrPromptVersionNotFoundPrompt version with the given ID does not exist

Conflict errors

ErrorDescription
ErrSuiteAlreadyExistsA suite with the same name already exists in this app

State errors

ErrorDescription
ErrInvalidStateInvalid state transition
ErrEmptyInputEmpty input provided

Evaluation errors

ErrorDescription
ErrNoTargetNo target configured for the evaluation
ErrNoScorersNo scorers configured for the case

Error wrapping

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 mapping

The HTTP API maps sentinel errors to HTTP status codes:

Sentinel errorHTTP status
ErrSuiteNotFound, ErrCaseNotFound, etc.404 Not Found
ErrSuiteAlreadyExists409 Conflict
ErrInvalidState, ErrEmptyInput400 Bad Request
ErrNoStore500 Internal Server Error

On this page