Error Model

Asset Core uses standard HTTP status codes with structured JSON error responses. This reference describes the error model and common error conditions.

Overview

Errors are returned as JSON objects with details about what failed and why. The HTTP status code indicates the error category, while the body provides specifics.

Structure

Error Response

{
  "error": {
    "code": "ErrorCode",
    "message": "Human-readable description",
    "details": {
      "field": "additional context"
    }
  }
}

Error Detail Fields

FieldTypeDescription
codestringMachine-readable error identifier
messagestringHuman-readable description
detailsobjectAdditional context (varies by error)
operation_indexintegerWhich operation failed (for transactions)

Fields

HTTP Status Codes

StatusMeaningWhen Used
200 OKSuccessRequest completed successfully
400 Bad RequestInvalid requestMalformed JSON, missing fields
404 Not FoundResource not foundContainer or class doesn’t exist
409 ConflictState conflictIdempotency key collision, already exists
422 Unprocessable EntityValidation failedOperation preconditions not met
500 Internal Server ErrorServer errorUnexpected failures
503 Service UnavailableTemporarily unavailableOverloaded, shutting down

Common Error Codes

Container Errors

CodeStatusDescription
ContainerNotFound404The specified container doesn’t exist
ContainerAlreadyExists409Container ID is already in use
WrongContainerKind422Operation not supported for this container kind

Balance Errors

CodeStatusDescription
InvalidQuantity422Quantity must be greater than zero
InsufficientBalance422Not enough balance for the operation
InvalidOperation422Operation would overflow or is invalid

Instance Errors

CodeStatusDescription
InstanceNotFound404The specified instance doesn’t exist
AlreadyAttached409Instance already has a parent
NotAttached422Instance has no parent to detach from
HasChildren422Must detach children before burning
WouldCreateCycle422Attachment would create a cycle

Slot Errors

CodeStatusDescription
SlotOutOfBounds422Slot index exceeds container capacity
SlotOccupied409Slot already contains an instance
SlotEmpty422Slot doesn’t contain an instance

Schema Errors

CodeStatusDescription
ClassNotFound404The specified class isn’t registered
ClassAlreadyExists409Class ID is already registered
ShapeAlreadyDefined409Shape ID already exists for this class
UnregisteredClassShape422Shape required but not registered

System Errors

CodeStatusDescription
ParseError400Invalid JSON in request body
ValidationError422Request validation failed
IntegerOverflow422Numeric operation would overflow
ServiceUnavailable503System is overloaded or shutting down

Examples

Bad Request (400)

Invalid JSON:

{
  "error": {
    "code": "ParseError",
    "message": "Failed to parse JSON body",
    "details": {
      "position": 42,
      "expected": "string"
    }
  }
}

Not Found (404)

Container doesn’t exist:

{
  "error": {
    "code": "ContainerNotFound",
    "message": "Container 1001 does not exist",
    "details": {
      "container_id": 1001
    }
  }
}

Conflict (409)

Idempotency key already used with different content:

{
  "error": {
    "code": "IdempotencyConflict",
    "message": "Idempotency key 'create-1001' was used with different request content",
    "details": {
      "idempotency_key": "create-1001"
    }
  }
}

Unprocessable Entity (422)

Insufficient balance:

{
  "error": {
    "code": "InsufficientBalance",
    "message": "Insufficient balance: requested 500, available 100",
    "details": {
      "container_id": 1001,
      "class_id": 100,
      "key": 1,
      "requested": 500,
      "available": 100
    },
    "operation_index": 0
  }
}

Service Unavailable (503)

System overloaded:

{
  "error": {
    "code": "ServiceUnavailable",
    "message": "System is at capacity, please retry later",
    "details": {
      "queue_depth": 1000,
      "retry_after_ms": 100
    }
  }
}