Error Handling
Sentinel errors returned by Shield operations.
Shield defines sentinel errors in the root shield 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 |
ErrMigrateFailed | Database migration failed |
| Error | Description |
|---|
ErrScanNotFound | Scan result with the given ID does not exist |
ErrPolicyNotFound | Policy with the given ID does not exist |
ErrInstinctNotFound | Instinct with the given ID does not exist |
ErrJudgmentNotFound | Judgment with the given ID does not exist |
ErrAwarenessNotFound | Awareness detector with the given ID does not exist |
ErrValueNotFound | Value with the given ID does not exist |
ErrReflexNotFound | Reflex with the given ID does not exist |
ErrBoundaryNotFound | Boundary with the given ID does not exist |
ErrProfileNotFound | Safety profile with the given ID does not exist |
ErrPIITokenNotFound | PII token with the given ID does not exist |
ErrComplianceNotFound | Compliance report with the given ID does not exist |
| Error | Description |
|---|
ErrAlreadyExists | A resource with the same name already exists |
| Error | Description |
|---|
ErrInputBlocked | Input content was blocked by safety scan |
ErrOutputBlocked | Output content was blocked by safety scan |
| Error | Description |
|---|
ErrNoProfile | No safety profile configured for the scan |
ErrInvalidConfig | Invalid engine configuration |
| Error | Description |
|---|
ErrEncryptionKeyMissing | PII encryption key not configured |
| Error | Description |
|---|
ErrInvalidState | Invalid state transition |
Store implementations wrap these sentinel errors with additional context:
return fmt.Errorf("postgres: get scan %s: %w", scanID, shield.ErrScanNotFound)
Check errors using errors.Is:
result, err := eng.GetScan(ctx, scanID)
if errors.Is(err, shield.ErrScanNotFound) {
// handle not found
}