---
title: Error Handling
description: 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`.

## Store errors

| Error | Description |
|-------|-------------|
| `ErrNoStore` | No store was configured on the engine |
| `ErrStoreClosed` | The store has been closed |
| `ErrMigrateFailed` | Database migration failed |

## Not-found errors

| 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 errors

| Error | Description |
|-------|-------------|
| `ErrAlreadyExists` | A resource with the same name already exists |

## Scan errors

| Error | Description |
|-------|-------------|
| `ErrInputBlocked` | Input content was blocked by safety scan |
| `ErrOutputBlocked` | Output content was blocked by safety scan |

## Engine errors

| Error | Description |
|-------|-------------|
| `ErrNoProfile` | No safety profile configured for the scan |
| `ErrInvalidConfig` | Invalid engine configuration |

## PII errors

| Error | Description |
|-------|-------------|
| `ErrEncryptionKeyMissing` | PII encryption key not configured |

## State errors

| Error | Description |
|-------|-------------|
| `ErrInvalidState` | Invalid state transition |

## Error wrapping

Store implementations wrap these sentinel errors with additional context:

```go
return fmt.Errorf("postgres: get scan %s: %w", scanID, shield.ErrScanNotFound)
```

Check errors using `errors.Is`:

```go
result, err := eng.GetScan(ctx, scanID)
if errors.Is(err, shield.ErrScanNotFound) {
    // handle not found
}
```
