Skip to content
This repository has been archived by the owner on Apr 20, 2018. It is now read-only.

unable to handle JSON.parse errors #122

Open
shakyShane opened this issue Aug 26, 2016 · 3 comments
Open

unable to handle JSON.parse errors #122

shakyShane opened this issue Aug 26, 2016 · 3 comments

Comments

@shakyShane
Copy link

JSON.parse can throw, but the way in which it's called in https://github.com/Reactive-Extensions/RxJS-DOM/blob/master/src/ajax/ajax.js#L40 means it's impossible to handle this error gracefully which completely breaks composition.

Shouldn't you be try/catching things that may throw inside the subscribeCore?

This is unexpected :

Rx.DOM.post({
    url, // let's say the response body contains invalid json
    responseType: 'json',
    body: ''
}).catch(err => {
    // Cannot handle the JSON.parse error here
});

The following should be possible

Rx.DOM.post({
    url,
    responseType: 'json',
    body: ''
}).catch(error => Rx.Observable.just({type: 'AJAX_ERROR', data: {error}}))

Currently, the error will bubble up and crash your program.

@IvanJov
Copy link

IvanJov commented Nov 23, 2017

This is still an issue in RxJS 5.

@paulpdaniels
Copy link
Contributor

@IvanJov RxJS 5 isn't maintained here.

@IvanJov
Copy link

IvanJov commented Nov 23, 2017

Yes, I know 😜
Just mentioning that this is still a problem, even in the newest version.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants