163
社区成员
发帖
与我相关
我的任务
分享
try:
.....
except xx as e:
.....
else:
.....
finally:
.....
Try(()=> doSth()).onSuccess(result => handleResult(result)).onFailure(e => handleException(e)).getOrElse(sth)
class Handler{
function Handler(func){
try{
this.result = func(...);
this.succeed = true;
}
catch{
this.succeed = false;
this.error = Exception.catched();
}
}
function onSucceed(func){
if(this.succeed){
func(this.result);
}
return this;
}
function onFailed(func){
if(!this.succeed){
func(this.error);
}
return this;
}
}
function Handle(func)
{
return new Handler(func, ...);
}
并非没有,而仅仅是语言不同而已。