Error Handling

Common Error Codes

CodeNameMeaning
4ErrUnauthorizedSigner is not the owner or authorized publisher
5ErrInvalidAddressMalformed bech32 address
18ErrInvalidRequestMissing required field or invalid data
11ErrOutOfGasTransaction ran out of gas
32ErrWrongSequenceAccount sequence mismatch (retry with correct sequence)

Module-Specific Errors

Procurement
  • ErrInvalidOCID -- OCID is empty or malformed
  • ErrProcessAlreadyExists -- Duplicate OCID
  • ErrProcessNotFound -- OCID not found
  • ErrUnauthorizedPublisher -- Not in authorized list
  • ErrEntityAlreadyExists -- Duplicate entity ID
  • ErrEntityNotFound -- Entity not found
Infrastructure
  • ErrInvalidProjectID -- Project ID is empty
  • ErrProjectAlreadyExists -- Duplicate project ID
  • ErrProjectNotFound -- Project not found
  • ErrUnauthorizedPublisher -- Not in authorized list

Response Format

A transaction code of 0 means success. Any non-zero code indicates failure.

json
// REST query error (Google RPC status)
{ "code": 3, "message": "invalid OCID: OCID cannot be empty", "details": [] }

// Transaction broadcast error
{ "tx_response": {
    "code": 18,
    "raw_log": "invalid request: release cannot be nil",
    "txhash": "ABC123...",
    "height": "0"
}}

Handling Sequence Errors

If you get ErrWrongSequence, re-fetch the account sequence and retry:

bash
curl "$API/cosmos/auth/v1beta1/accounts/cosmos1abc..."
typescript
// CosmJS handles this automatically with "auto" gas.
// For manual signing, fetch the latest sequence:
const account = await client.getAccount(address);
// account.sequence => next expected sequence number