Error Handling
Common Error Codes
| Code | Name | Meaning |
|---|---|---|
| 4 | ErrUnauthorized | Signer is not the owner or authorized publisher |
| 5 | ErrInvalidAddress | Malformed bech32 address |
| 18 | ErrInvalidRequest | Missing required field or invalid data |
| 11 | ErrOutOfGas | Transaction ran out of gas |
| 32 | ErrWrongSequence | Account sequence mismatch (retry with correct sequence) |
Module-Specific Errors
Procurement
ErrInvalidOCID-- OCID is empty or malformedErrProcessAlreadyExists-- Duplicate OCIDErrProcessNotFound-- OCID not foundErrUnauthorizedPublisher-- Not in authorized listErrEntityAlreadyExists-- Duplicate entity IDErrEntityNotFound-- Entity not found
Infrastructure
ErrInvalidProjectID-- Project ID is emptyErrProjectAlreadyExists-- Duplicate project IDErrProjectNotFound-- Project not foundErrUnauthorizedPublisher-- 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