Shield defines sentinel errors in the root shield 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 |
ErrMigrateFailed | Database migration failed |
Not-found errors02
| 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 |
Conflict errors03
| Error | Description |
ErrAlreadyExists | A resource with the same name already exists |
Scan errors04
| Error | Description |
ErrInputBlocked | Input content was blocked by safety scan |
ErrOutputBlocked | Output content was blocked by safety scan |
Engine errors05
| Error | Description |
ErrNoProfile | No safety profile configured for the scan |
ErrInvalidConfig | Invalid engine configuration |
PII errors06
| Error | Description |
ErrEncryptionKeyMissing | PII encryption key not configured |
State errors07
| Error | Description |
ErrInvalidState | Invalid state transition |
Error wrapping08
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
}