JavaScript Promise迷你书(中文版)
..................................................................................... 20 Promise#catch ................................................................................................. .................................................................................... 39 then or catch? ................................................................................................ ................................................................................... 107 Promise#catch .................................................................................................0 码力 | 112 页 | 1010.02 KB | 1 年前3JavaScript Promiseの本 v2
..................................................................................... 22 Promise#catch ................................................................................................. .................................................................................... 45 then or catch? ................................................................................................ .................................................................................... 131 Promise#catch ................................................................................................0 码力 | 137 页 | 1.17 MB | 1 年前3JavaScript Promiseの本 v1
..................................................................................... 21 Promise#catch ................................................................................................. .................................................................................... 41 then or catch? ................................................................................................ .................................................................................... 110 Promise#catch ................................................................................................0 码力 | 115 页 | 1.06 MB | 1 年前3Exceptionally Bad: The Story on the Misuse of Exceptions and How to Do Better
seen in C++ • Look at original goals/ideals of exception handling • Look at the mechanics of throw/catch • Look at Exceptions in both their use and design as seen in real code • Better thinking on the me{"Pete", 21}; apply(me); } catch (const MyStatus& s) { std::cout << "error : " << s << std::endl; } ... } } Error handling Happy Path (clean) Function signature changed } catch (...) { std::cout << Exception hygiene • Throw by value • Catch by (const) reference • Rethrow using throw with no arguments • Catch handlers with derived classes placed before catch handlers with base classes Exception0 码力 | 85 页 | 2.32 MB | 5 月前3C++ Exceptions for Smaller Firmware
throw 5; } int main() { volatile int return_code = 0; try { return_code = start(); } catch (...) { return_code = -1; } return return_code; } 51Barrier #1 Exceptions disabled! 52☠ to convince you That was to show you that something is here. 94C++ Exceptions from throw to catch on GCC ARM 95Things that will NOT be covered here ● Nested exceptions ● Anything other than table based exceptions 96Consider the following 97 struct error {}; void foo() { try { bar(); } catch (error const& p_error) { // end up here... } } void bar() { destructible_t obj; baz();0 码力 | 237 页 | 6.74 MB | 5 月前3阮一峰 《ECMAScript 6入门》 第三版
true } }; // Load your module System.import('./myModule.js', {metadata: metadata}).catch(fun ction(ex) { console.error('Import failed', ex.stack || ex); }); 上面代码中,首先生成Traceur的全局对象 let 和 const 命令 33 // 情况一 if (true) { function f() {} } // 情况二 try { function f() {} } catch(e) { // ... } 上面两种函数声明,根据 ES5 的规定都是非法的。 但是,浏览器没有遵守这个规定,为了兼容以前的旧代码,还是支持在块级作用域 之中声明函数,因此上面两种情况实际都能运行,不会报错。 这样的规定也使得,函数参数与数组和对象的尾逗号规则,保持一致了。 catch 语句的参数 函数的扩展 165 目前,有一个提案,允许 try...catch 结构中的 catch 语句调用时不带有参 数。这个提案跟参数有关,也放在这一章介绍。 传统的写法是 catch 语句必须带有参数,用来接收 try 代码块抛出的错误。 try { // ··· } catch (error) { // ···0 码力 | 679 页 | 2.66 MB | 1 年前3Exceptions Under the Spotlight
to throw by value, catch by const ref, and re-throw using throw.• A fail-handling mechanism void bar() { try { foo(); } catch (error_type) { // do stuff, or re-throw; } catch (…) { // do stuff, responsibility 9• A fail-handling mechanism int main() { try { bar(); } catch (error_type) { // do stuff } // don’t catch; } “Re-delegate responsibility” PART 0: WHAT ARE EXCEPTIONS 10PART I: (expensive, un-deterministic mechanism) • C++ does not return tothe throwing code (but to the catch block). Exception handlers are rare compared to function definitions. The formal usage recommendation0 码力 | 53 页 | 2.82 MB | 5 月前3[JavaSE实验] JDBC and MySQL
if (rs.next()) { System.out.println(rs.getString(1)); } } catch (SQLException ex) { Logger lgr = Logger.getLogger(Version.class.getName()); if (con != null) { con.close(); } } catch (SQLException ex) { Logger lgr = Logger.getLogger(Version.class.getName()); The getString() method retrieves the value of a specified column. The first column has index 1. } catch (SQLException ex) { Logger lgr = Logger.getLogger(Version.class.getName()); lgr.log(Level0 码力 | 23 页 | 2.52 MB | 1 年前3Back to Basics: Exceptions
try { g(); h(); } catch( std::exception const& ex ) { /* Handle exception */ } } Three keywords throw try catch Stack unwinding Objects on the stack are try { g(); h(); } catch( std::exception const& ex ) { /* Handle exception */ } } Three keywords throw try catch Stack unwinding Objects on the stack are try { g(); h(); } catch( std::exception const& ex ) { /* Handle exception */ } } Three keywords throw try catch Stack unwinding Objects on the stack are0 码力 | 111 页 | 4.87 MB | 5 月前3The Swift Programming Language (Swift 5.7) - Apps Dissected
ways to handle errors. One way is to use do-catch. Inside the do block, you mark code that can throw an error by writing try in front of it. Inside the catch block, the error is automatically given the printerResponse = try send(job: 1040, toPrinter: "Bi Sheng") 3 print(printerResponse) 4 } catch { 5 print(error) 6 } 7 // Prints "Job sent" E X P E R I M E N T Change the printer name send(job:toPrinter:) function throws an error. You can provide multiple catch blocks that handle specific errors. You write a pattern after catch just as you do after case in a switch. PDF conversion courtesy0 码力 | 1040 页 | 10.90 MB | 1 年前3
共 1000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 100