I think this proposal has the risk of swallowing too many errors making code hard to debug and would therefore suggest this shouldn’t be added to the language. Silent errors are hard to find the origin and cause for especially if you throw away the error message.
This might be slightly off topic but, I think we should instead wait for proper pattern matching and include a Result type similar to Scala Option or Haskell Either that is falsy in the Left error case (containing the error message) and truthy otherwise. 2017年8月11日(金) 10:17 Hikaru Nakashima <oao.hikaru....@gmail.com>: > I think this idea is useful in async function. > > For exsample, we write codes as below, when we use fetch() in async > function. > > ```js > > let res, text > > try { > res = await fetch( url ) > } catch ( err ) { console.log( 'network error' ) } > > if ( ! res.ok ) console.log( 'server error' ) > else text = await res.text( ) > > > ``` > > or > > ```js > > let res, text > > res = await fetch( url ).catch( err => null ) > if ( ! res ) console.log( 'network error' ) > > else if ( ! res.ok ) console.log( 'server error' ) > else text = await res.text( ) > > > ``` > > but, we can write as below if we use this proposal. > > ```js > > let res, text > > res = try await fetch( url ) > if ( ! res ) console.log( 'network error' ) > > else if ( ! res.ok ) console.log( 'server error' ) > else text = await res.text( ) > > ``` > > or do we need another syntax like "await?" ? > _______________________________________________ > es-discuss mailing list > es-discuss@mozilla.org > https://mail.mozilla.org/listinfo/es-discuss >
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss