Chronicle

Error Handling

Sentinel errors returned by Chronicle operations.

Chronicle defines sentinel errors in the root chronicle package. Use errors.Is to check for them:

import (
    "errors"
    "github.com/xraph/chronicle"
)

event, err := c.GetEvent(ctx, id)
if errors.Is(err, chronicle.ErrEventNotFound) {
    // handle not-found
}

Sentinel errors

ErrorDescription
chronicle.ErrNoStoreNo store configured — chronicle.New called without WithStore.
chronicle.ErrEventNotFoundThe requested audit event does not exist.
chronicle.ErrStreamNotFoundThe requested hash chain stream does not exist.
chronicle.ErrChainBrokenHash chain verification detected tampering or a gap.
chronicle.ErrSubjectNotFoundThe requested GDPR data subject does not exist.
chronicle.ErrPolicyNotFoundThe requested retention policy does not exist.
chronicle.ErrReportNotFoundThe requested compliance report does not exist.
chronicle.ErrErasureNotFoundThe requested erasure record does not exist.
chronicle.ErrErasureKeyNotFoundThe per-subject encryption key has been destroyed or never existed. Returned after successful crypto-erasure when attempting to decrypt.
chronicle.ErrInvalidQueryA query has invalid or missing parameters.
chronicle.ErrUnauthorizedThe caller lacks permission for the requested operation.
chronicle.ErrStoreClosedAn operation was attempted on a closed store.
chronicle.ErrMigrationFailedDatabase schema migrations failed on Start.

Plugin error

The plugin package defines one additional sentinel:

ErrorDescription
plugin.ErrSkipEventReturned by a BeforeRecord plugin to abort recording the current event without treating it as an error.
func (p *MyPlugin) OnBeforeRecord(ctx context.Context, event *audit.Event) error {
    if event.Category == "internal" {
        return plugin.ErrSkipEvent // silently drop the event
    }
    return nil
}

HTTP API error format

The Admin API returns errors as JSON:

{"error": "chronicle: event not found"}

Status codes:

CodeCondition
400Invalid request body or query parameters
401Missing AppID in context (no scope)
404Entity not found
500Unexpected internal error

On this page