errors.sol

Overview

The errors.sol file defines an abstract contract named Errors that serves as a centralized repository of error codes used throughout the system. These error codes are represented as constant unsigned 16-bit integers (uint16) and provide a standardized way to identify specific error conditions programmatically. The contract also includes a version string versionErrors to track the version of the error code definitions.

This approach facilitates consistent error handling and reporting across different smart contracts or components in the system by referencing predefined error codes instead of using arbitrary values or strings.

Contract: Errors

Declaration

abstract contract Errors {
    string constant versionErrors = "6.2.0";
    // Numerous uint16 constant error codes follow...
}

Error Code Constants

The contract declares a comprehensive list of error codes as uint16 constants. Each constant has a unique numerical value and a descriptive name indicating the nature of the error condition it represents.

Structure and Naming

Usage

Other contracts or modules can reference these constants to:

Examples

// Example: Returning an error code when sender is not authorized
function someFunction() public returns (uint16) {
    if (msg.sender != daoAddress) {
        return ERR_SENDER_NOT_DAO; // Value 202
    }
    // Normal function logic
    return NOT_ERR; // No error
}
// Example: Checking error code returned from a call
uint16 errorCode = externalContract.someFunction();
if (errorCode == ERR_LOW_BALANCE) {
    // Handle low balance error
}

Selected Error Codes and Their Possible Meanings

Constant Name

Code

Description (Inferred)

ERR_NO_SALT

200

Missing or invalid salt value in operation

ERR_SENDER_NOT_DAO

202

Sender is not authorized DAO entity

ERR_ZERO_ROOT_KEY

203

Root key is zero or uninitialized

ERR_LOW_VALUE

204

Provided value is too low

ERR_NOT_ROOT_REPO

205

Not the root repository

ERR_DOUBLE_MSG

209

Duplicate message detected

ERR_NOT_OWNER

212

Operation attempted by non-owner

ERR_BRANCH_NOT_EXIST

213

Referenced branch does not exist

ERR_TOO_MANY_PARENTS

216

Exceeded allowed number of parent entities

ERR_WRONG_NAME

222

Invalid name format or value

NOT_ERR

223

Special code indicating no error

ERR_WALLET_NOT_EXIST

225

Wallet does not exist

ERR_TOO_MANY_TAGS

266

Exceeded allowed number of tags

ERR_NOT_ALLOW_MINT

268

Minting is not allowed in the current context

ERR_TOO_MANY_PROPOSALS

273

Exceeded maximum number of proposals

ERR_WALLET_BUSY

300

Wallet is currently busy or locked

ERR_ALREADY_SLASH

302

Penalty (slash) has already been applied

This list is not exhaustive; the file contains many more error codes covering a wide range of possible failure or invalid states related to authorization, data integrity, state conditions, and business logic constraints.

Implementation Details

Interaction with Other System Components

For more context on error handling and best practices for error codes in smart contracts, see Error Handling in Smart Contracts.


Mermaid Diagram

classDiagram
class Errors {
+string versionErrors
+uint16 ERR_NO_SALT
+uint16 ERR_SENDER_NOT_DAO
+uint16 ERR_ZERO_ROOT_KEY
+uint16 ERR_LOW_VALUE
+uint16 ERR_NOT_OWNER
+uint16 ERR_BRANCH_NOT_EXIST
+uint16 ERR_TOO_MANY_PARENTS
+uint16 NOT_ERR
+uint16 ERR_WALLET_NOT_EXIST
+uint16 ERR_TOO_MANY_TAGS
+uint16 ERR_NOT_ALLOW_MINT
+uint16 ERR_TOO_MANY_PROPOSALS
+uint16 ERR_WALLET_BUSY
+uint16 ERR_ALREADY_SLASH
}

The diagram illustrates that the Errors contract contains multiple constant properties representing error codes and a version string. No methods are defined.