codecamp

错误处理

有关错误处理以及何时使用哪个函数的更多详细信息,请参阅有关断言和要求的专用部分。

assert(bool condition)

如果条件不满足,则会导致 Panic 错误并因此状态更改恢复 - 用于内部错误。

require(bool condition)

如果条件不满足,则恢复 - 用于输入或外部组件中的错误。

require(bool condition, string memory message)

如果条件不满足,则恢复 - 用于输入或外部组件中的错误。还提供错误消息。

revert()

中止执行并恢复状态更改

revert(string memory reason)

中止执行并恢复状态更改,提供解释性字符串


字符串成员
数学和密码函数
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }