Docs / Reference

Errors

pqlock fails closed with a small set of error types. Open and verify never say which check failed, so errors cannot be used as an oracle.

01Error types

MeaningTypeScriptPythonGo
Base classPQLErrorPQLErrorwrapped errors
Envelope did not openPQLOpenErrorOpenErrorpql.ErrOpen
Signature, token, webhook or call rejectedPQLVerifyErrorVerifyErrorpql.ErrVerify
Bad or wrong-purpose keysetPQLErrorKeysetErrorpql.ErrKeyset
Bad policy filePQLErrorPolicyErrorpql.ErrPolicy
try { seal.open(keys, text); }
catch (err) { if (err instanceof PQLOpenError) return null; throw err; }
try:
    seal.open(text, keys)
except OpenError:
    return None
if _, err := seal.OpenText(keys, text); errors.Is(err, pql.ErrOpen) {
    return nil
}

02Errors with reasons

Webhook and agent-call rejections extend the verify error with a reason, because the receiver often needs to answer differently to a replay than to a bad signature:

ErrorReasons
WebhookErrormalformed, unknown_key, expired, bad_signature, replay, cache_full
CallErrormalformed, args, agent, signature, stale, replay

03What errors never do

pqlock v0.1.0 · unaudited preview · source of truth: spec/