多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
[TOC] ## 异常 ``` throw FormatException('Expected at least 1 section'); throw 'Out of llamas!'; // 抛出任意的对象 try { throw FormatException("1111"); // throw "222"; } on Exception catch (e) { // 其他任何异常 print('Unknown exception: $e'); //1111 } catch (e) { // 没有指定的类型,处理所有异常 print('Something really unknown: $e'); // 222 } ``` ### 重新抛出异常 ``` try { dynamic foo = true; print(foo++); // Runtime error } catch (e) { print('misbehave() partially handled ${e.runtimeType}.'); rethrow; // Allow callers to see the exception. } ``` ### finally ``` try { throw "222"; } catch (e) { print('Something really unknown: $e'); } finally{ print("end"); //end } //output // Something really unknown: 222 //end ```