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
[email protected]
https://mail.mozilla.org/listinfo/es-discuss