errors.sol
Overview
This file defines the Errors abstract contract that centralizes error code constants used across the system. It provides a standardized set of numeric error identifiers, each representing a specific error condition that can occur within various smart contracts or modules. The contract acts as a common reference point for error handling, enabling consistent error reporting and interpretation throughout the application.
The error codes are declared as uint16 constants, each mapped to a unique numeric value and a descriptive identifier. Additionally, a versionErrors string constant specifies the version of the error definitions, facilitating version tracking and compatibility checks.
Contract: Errors
Purpose
The Errors contract is designed as an abstract contract, meaning it is intended to be inherited by other contracts rather than deployed on its own. By inheriting from Errors, other contracts gain access to a comprehensive list of predefined error codes, which they can use to signal various failure conditions.
Properties
Property | Type | Description |
|---|---|---|
|
| Indicates the current version of the error codes ( |
|
| Numeric error codes representing specific error scenarios. |
Error Codes Description
Each error constant represents a unique error condition. For example:
ERR_NO_SALT (200): Indicates that a required cryptographic salt value is missing.ERR_SENDER_NOT_DAO (202): The sender is not authorized as a DAO (Decentralized Autonomous Organization).ERR_ZERO_ROOT_KEY (203): The root key provided is zero or invalid.ERR_LOW_VALUE (204): The provided value is too low.ERR_NOT_OWNER (212): The caller is not the owner of the resource.ERR_BRANCH_NOT_EXIST (213): A specified branch does not exist.ERR_TOO_MANY_PARENTS (216): Too many parent nodes were specified.ERR_MESSAGE_EXPIRED (250): A message has expired.ERR_TASK_COMPLETED (256): An operation failed because the task is already completed.ERR_WRONG_BLS_PUBKEY (279): The provided BLS public key is invalid.ERR_STAKE_DIDNT_EXIST (280): A stake that is expected does not exist.
These codes cover a wide range of error conditions related to permissions, state validations, data integrity, contract versioning, and domain-specific logic such as wallets, branches, tasks, and proposals.
Usage Example
Contracts inheriting from Errors can use the defined constants to revert with specific error codes, facilitating easier debugging and error handling. For example:
contract MyContract is Errors {
function doSomething(uint value) external {
if (value == 0) {
revert(string(abi.encodePacked("Error ", uint(ERR_LOW_VALUE))));
}
}
}
This pattern allows external callers and interfaces to programmatically interpret the error codes returned from contract calls.
Implementation Details
The contract is declared as
abstract, indicating it is not intended to be instantiated directly.All error codes are declared as
uint16 constantfor efficient storage and to ensure immutability.The error codes start at 200 and increment sequentially with some gaps, allowing for future additions without conflict.
The contract uses the
pragma gosh-solidity >=0.76.1;directive, specifying the compiler version or variant used.No methods or functions are defined, reflecting the contract’s sole purpose as a container for error constants.
The error naming convention uses the prefix
ERR_followed by a descriptive identifier in uppercase snake case.
Interaction with Other System Components
The
Errorscontract serves as a foundational component, intended to be inherited by other smart contracts within the system.By referencing these error codes, other contracts ensure uniform error signaling and handling, simplifying cross-contract integration and debugging.
This design pattern aligns with best practices in smart contract development for modularity and maintainability.
The error codes likely correspond to specific business logic and validation rules implemented elsewhere, such as in DAO management, wallet operations, branch and commit handling, task management, and governance proposals.
Versioning via
versionErrorshelps maintain synchronization between the error definitions and the contracts consuming them, especially during upgrades or migrations.
Diagram
classDiagram
class Errors {
<<abstract>>
+versionErrors: string
+ERR_NO_SALT: uint16
+ERR_SENDER_NOT_DAO: uint16
+ERR_ZERO_ROOT_KEY: uint16
+ERR_ZERO_ROOT_GOSH: uint16
+ERR_LOW_VALUE: uint16
+ERR_NOT_ROOT_REPO: uint16
+ERR_INVALID_SENDER: uint16
+ERR_LOW_BALANCE: uint16
+ERR_DOUBLE_MSG: uint16
+ERR_SENDER_NO_ALLOWED: uint16
+ERR_NO_DATA: uint16
+ERR_NOT_OWNER: uint16
+ERR_BRANCH_NOT_EXIST: uint16
+ERR_NOT_EMPTY_BRANCH: uint16
+ERR_BRANCH_EXIST: uint16
+ERR_TOO_MANY_PARENTS: uint16
+ERR_SECOND_CHANGE: uint16
+ERR_NOT_LAST_CHECK: uint16
+ERR_DONT_PASS_CHECK: uint16
+ERR_WRONG_COMMIT_ADDR: uint16
+ERR_NEED_PUBKEY: uint16
+ERR_WRONG_NAME: uint16
+NOT_ERR: uint16
+ERR_WRONG_KEY: uint16
+ERR_WALLET_NOT_EXIST: uint16
+ERR_WRONG_BRANCH: uint16
+ERR_DIFF_ALREADY_USED: uint16
+ERR_PROCCESS_IS_EXIST: uint16
+ERR_PROCCESS_END: uint16
+ERR_NO_NEED_ANSWER: uint16
+ERR_WRONG_DATA: uint16
+ERR_NOT_EMPTY_DATA: uint16
+ERR_SNAPSHOT_NOT_READY: uint16
+ERR_EMPTY_BRANCH: uint16
+ERR_GOSH_UPDATE: uint16
+ERR_OLD_CONTRACT: uint16
+ERR_SYSTEM_CONTRACT_BAD_VERSION: uint16
+ERR_BAD_COUNT_PARENTS: uint16
+ERR_REPOSITORY_NOT_READY: uint16
+ERR_PREV_NOT_EXIST: uint16
+ERR_WRONG_DAO: uint16
+ERR_TOMBSTONE: uint16
+ERR_BAD_NUMBER_CUSTODIANS: uint16
+ERR_NOTHING_TO_CONFIRM: uint16
+ERR_ALREADY_CONFIRMED: uint16
+ERR_WRONG_NUMBER_MEMBER: uint16
+ERR_BAD_PARENT: uint16
+ERR_TOO_LOW_BALANCE: uint16
+ERR_FIRST_DAO: uint16
+ERR_MESSAGE_EXPIRED: uint16
+ERR_MESSAGE_WITH_HUGE_EXPIREAT: uint16
+ERR_MESSAGE_IS_EXIST: uint16
+ERR_TOO_MANY_DIFFS: uint16
+ERR_CONTRACT_BAD_VERSION: uint16
+ERR_NOT_ALONE: uint16
+ERR_TASK_COMPLETED: uint16
+ERR_TASK_NOT_COMPLETED: uint16
+ERR_ASSIGN_NOT_EXIST: uint16
+ERR_REVIEW_NOT_EXIST: uint16
+ERR_MANAGER_NOT_EXIST: uint16
+ERR_NEED_SMV: uint16
+ERR_BRANCH_PROTECTED: uint16
+ERR_WALLET_LIMITED: uint16
+ERR_LOW_TOKEN_RESERVE: uint16
+ERR_LOW_TOKEN: uint16
+ERR_TOO_MANY_TAGS: uint16
+ERR_NOT_READY: uint16
+ERR_NOT_ALLOW_MINT: uint16
+ERR_DIFFERENT_COUNT: uint16
+ERR_TOO_MANY_VESTING_TIME: uint16
+ERR_ZERO_GRANT: uint16
+ERR_WRONG_LOCK: uint16
+ERR_TOO_MANY_PROPOSALS: uint16
+ERR_TOO_FEW_PROPOSALS: uint16
+ERR_WRONG_UPGRADE_STATUS: uint16
+ERR_WALLET_EXIST: uint16
+ERR_PROGRAM_EXIST: uint16
+ERR_PROGRAM_NOT_EXIST: uint16
+ERR_WRONG_BLS_PUBKEY: uint16
+ERR_STAKE_DIDNT_EXIST: uint16
}