error_codes.md

October 29, 2021 ยท View on GitHub

Error codes in 0L has two components:

  • The error reason
  • The error category

Error Reason

The error reason has three components:

  • The file prefix (the first character and a counter). e.g 1801 in Reconfigmodule. Refer to table below
  • index of function (found in file). e.g. 06 for process_outgoing
  • index of Assert in that function e.g. 02 for the second Transaction::Assert

For instance: Reconfig there could be a file prefix number e.g 1801 appended by an index for the function like e.g 06 for process_outgoing, then an index of all errors within that function, e.g. on the second assert 02. The corresponding error reason is 1801 & 06 & 02 === 18010602

File Prefix

The file prefix is based on first character and counter. Alphabet to number conversion: a=01, b=02, ... z=26. The next two digits form the counter, which starts at 0 and is incremented if two files have same first character.

The mapping of prefix is available in this table.

CodeFilename
0100Autopay
0300Cases
0400Demos
0500Epoch
0600FullNodeState
0700Globals
1200LibraSystem
1201LibraAccount
1301MinerState
1401NodeWeight
1500Oracle
1800Reconfigure
1900Stats
1901Subsidy
1903Stagingnet
2000TransactionFee
2001TrustedAccounts
2002Testnet
2100Upgrade
2200ValidatorConfig
2201ValidatorUniverse

Error Categories

  • INVALID_STATE - checks if testnet or mainnet
  • REQUIRES_ADDRESS
  • REQUIRES_ROLE - authorization required
  • REQUIRES_CAPABILITY
  • NOT_PUBLISHED - resource is not present
  • ALREADY_PUBLISHED
  • INVALID_ARGUMENT
  • LIMIT_EXCEEDED
  • INTERNAL
  • CUSTOM