Akashik Protocol
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

CodeRaised byWhen
INTENT_REQUIREDwrite, draft, discard, retract, supersedeintent is missing, null, or undefined
INTENT_TOO_SHORTwrite, draft, discard, retract, supersedeintent.trim().length < minIntentLength
INVALID_ENTRYwrite, draft, supersede, registerentry is not a plain object, or capabilities is not a string array
INVALID_QUERYread, attune, reckonquery is not a plain object, or max_units is negative
AGENT_REQUIREDregister, attune, reckon, retract, supersedeid, role, or agent is missing, empty, or not a string
INVALID_ENVELOPEAnyMessage envelope validation failed (malformed protocol message)
DRAFT_NOT_FOUNDcommit, discardNo draft exists with the given draft_id
RETRACT_NOT_AUTHORIZEDretractagent does not match the entry's original author
ENTRY_NOT_FOUNDretract, supersedeNo 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'