taohe

Move smart contracts implementing nestable resources on MoveVM blockchains

View on GitHub

Module 0x2f66c09143acc52a85fec529a4e20c85::Errors

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.

Constants

const CATEGORY_TAOHE: u8 = 128;

const TAO_GENERAL: u8 = 1;

const TAO_OWNABLE: u8 = 3;

const TAO_TIMELOCK: u8 = 2;

Function make

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

Function general

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

Function timelock_too_early

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

Function ownable_not_owned

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;