合规国际互联网加速 OSASE为企业客户提供高速稳定SD-WAN国际加速解决方案。 广告
[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 ```