Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistencies in Error reporting between recycleJSON true and false #16

Open
jameslaneconkling opened this issue Sep 1, 2017 · 2 comments

Comments

@jameslaneconkling
Copy link
Contributor

const model = new Model({
  source: {
    get: () => Observable.timer(100)
      .concat(Observable.throw({
        status: 500
      }))
  },
  recycleJSON
})


model.get(['items', 0, 'title'])  
  .subscribe({
    error(err) {
      console.log('Error', err)
    }
  });

If recycleJSON is true, logs:

// > { $type: 'error', value: { status: 500 } }

If recycleJSON is false, logs:

// > [{ "path": ["items", 0, "title"], "value": { "status":500 } }]
@jameslaneconkling
Copy link
Contributor Author

actually, looks like recyleJSON: true just sets treatErrorsAsValues, which is fine by me. However, another inconsistency arises:

const model = new Model({
  source: {
    get: () => Observable.timer(100)
      .concat(Observable.throw({
        status: 500
      }))
  },
  recycleJSON
})
  .treatErrorsAsValues();


model.get(['items', 0, 'title'])  
  .subscribe({
    next(data) {
      console.log('Data', data);
    }
    error(err) {
      console.log('Error', err);
    }
  });

If recycleJSON is true, logs:

// > Error: { $type: 'error', value: { status: 500 } }

If recycleJSON is false, logs:

// > Data: { "items": {"0": {"title": { "status": 500 } } } }
// > Error: { $type: 'error', value: { status: 500 } }

And if run against Netflix's model, logs:

// > Data: { "items": {"0": {"title": { "status": 500 } } } }

I'm not 100% sure what the desirable behavior is. Probably makes sense for behavior to be consistent between recycleJSON true/false. Not sure whether or not it also makes sense to track behavior in Netflix's model as well...

@trxcllnt
Copy link
Contributor

trxcllnt commented Sep 4, 2017

@jameslaneconkling you're right, the recycleJSON version should be onNext'ing value at minimum. Will look into it now.

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

No branches or pull requests

2 participants