Closed XuJiandong closed 2 months ago
How about adding an item that is never used to occupy errcode 0
, like this:
pub enum Error {
SkipCode0, // ensure this item would never be used
IndexOutOfBound,
LengthNotEnough,
ItemMissing,
....
}
use this
pub enum Error {
IndexOutOfBound = 1,
LengthNotEnough,
ItemMissing,
....
}
use this
pub enum Error { IndexOutOfBound = 1, LengthNotEnough, ItemMissing, .... }
Good advice!
The first error code(IndexOutOfBound) is with value zero: https://github.com/APRO-Oracle/apro-ckb-contract/blob/ed6a352b05ad30809a1656ff73615a97bd2a19cc/contracts/contract/src/common/error.rs#L5
It returns zero as success when IndexOutOfBound occurs: https://github.com/APRO-Oracle/apro-ckb-contract/blob/ed6a352b05ad30809a1656ff73615a97bd2a19cc/contracts/contract/src/main.rs#L36