Errors
Solidity 常用 require、revert 和字符串错误信息。Move 更常用 assert! 加数字错误码,并通过 error 模块补充上下文。
Solidity
Section titled “Solidity”function onlyOwner() external { require(msg.sender == address(1), "Contract: not owner");}use std::error;use std::signer;
const ENOT_OWNER: u64 = 1;
entry public fun only_owner(owner: &signer) { assert!( signer::address_of(owner) == @0x1, error::permission_denied(ENOT_OWNER) );}迁移时最重要的区别在于:Move 错误设计优先追求可机器稳定识别,人类可读性则由文档、常量命名和上下文补足。