This is to improve our error handling, and to make it more informative.
We follow the "category" approach of Diem Standard Library, with additional "subcategory" for different taos. Subcategories start from 1, so a TaoHe error message can be distinguished from other error messages by: category == 0x80 and subcategory >= 0x01.
const CATEGORY_TAOHE: u8 = 128;
const TAO_GENERAL: u8 = 1;
const TAO_OWNABLE: u8 = 3;
const TAO_TIMELOCK: u8 = 2;
Adapted from Diem Standard Library's Errors.move. Added tao identifier.
fun make(tao_id: u8, reason: u64): u64
Implementation
fun make(tao_id: u8, reason: u64): u64 {
(reason << 16) | ((tao_id as u64) << 8) | (CATEGORY_TAOHE as u64)
}
Specification
This is used for general TaoHe errors, not part of any specific module.
public fun general(reason: u64): u64
Implementation
public fun general(reason: u64): u64 { make(TAO_GENERAL, reason) }
Specification
This code is used by Timelock.move when unlock time haven't passed yet.
public fun timelock_too_early(): u64
Implementation
public fun timelock_too_early(): u64 { make(TAO_TIMELOCK, 15) }
Specification
This code is used by Ownable.sol when the account
is not the owner.
public fun ownable_not_owned(): u64
Implementation
public fun ownable_not_owned(): u64 { make(TAO_OWNABLE, 15) }
Specification
pragma aborts_if_is_strict;