ded / reqwest

browser asynchronous http requests
2.94k stars 341 forks source link

No err was throwed when network disconnected #271

Open BuggMaker opened 6 years ago

BuggMaker commented 6 years ago

reqwest(reqParams).then( (res: IResponse = {}) => { td = Date.now() - ts; resolve({ tinem: moment().format('HH:mm:ss'), msg: res.resultMsg || 'OK', delay: td }); }, (error: any) => { td = Date.now() - ts; reject({ time: moment().format('HH:mm:ss'), msg: error.resultMsg || 'Network disconnected!', delay: td, }); } );

When I use to like this, the network disconnect won't trigger an exception. And scan the source code, I find that there doesn't have a 'try-catch' or 'throw' as follows: function handleJsonp(o, fn, err, url) { ... // Add the script to the DOM head head.appendChild(script) // error happens, but not handle ... } }