Reference
Errors
AkashikError — the single error type raised by the v0.2 SDK.
AkashikError
Every rejection from the SDK is an AkashikError instance. It extends the built-in Error.
import { AkashikError } from '@akashikprotocol/core'
class AkashikError extends Error {
readonly code: AkashikErrorCode
readonly details?: Record<string, unknown>
}
code— stable string literal. Renaming one is a breaking change.details— error-specific diagnostic context. Shape per code is informational, not structural.message— human-readable description, not stable across releases.
Catching errors
import { AkashikError } from '@akashikprotocol/core'
try {
await field.retract({ id: 'xyz', intent: 'cleaning up', agent: 'other-agent' })
} catch (e) {
if (e instanceof AkashikError) {
switch (e.code) {
case 'RETRACT_NOT_AUTHORIZED':
console.error('Only the author can retract this entry')
break
case 'ENTRY_NOT_FOUND':
console.error('Entry does not exist')
break
default:
throw e
}
} else {
throw e
}
}
Error codes
| Code | Raised by | When |
|---|---|---|
INTENT_REQUIRED | write, draft, discard, retract, supersede | intent is missing, null, or undefined |
INTENT_TOO_SHORT | write, draft, discard, retract, supersede | intent.trim().length < minIntentLength |
INVALID_ENTRY | write, draft, supersede, register | entry is not a plain object, or capabilities is not a string array |
INVALID_QUERY | read, attune, reckon | query is not a plain object, or max_units is negative |
AGENT_REQUIRED | register, attune, reckon, retract, supersede | id, role, or agent is missing, empty, or not a string |
INVALID_ENVELOPE | Any | Message envelope validation failed (malformed protocol message) |
DRAFT_NOT_FOUND | commit, discard | No draft exists with the given draft_id |
RETRACT_NOT_AUTHORIZED | retract | agent does not match the entry's original author |
ENTRY_NOT_FOUND | retract, supersede | No entry exists with the given id |
Full error code type
type AkashikErrorCode =
| 'INTENT_REQUIRED'
| 'INTENT_TOO_SHORT'
| 'INVALID_ENTRY'
| 'INVALID_QUERY'
| 'AGENT_REQUIRED'
| 'INVALID_ENVELOPE'
| 'DRAFT_NOT_FOUND'
| 'RETRACT_NOT_AUTHORIZED'
| 'ENTRY_NOT_FOUND'