-
Notifications
You must be signed in to change notification settings - Fork 26
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
WIP: better errors #78
Conversation
@NullVoxPopuli Is this conform Ember Data conventions? Should we not reject with an error instead of throwing an exception? |
The need to have an exception object is for the help of consumers to the addon. Once it hits the console there is a stack trace, There is a clear error message that developers can understand. And as an object a developer can easily catch the error and choose to deal with it (i.e. offer a friendly not found message translated correctly). As for the difference between reject vs throw these are exactly the same thing. There is no difference. If you throw inside a |
FWIW, @frederikbosch I plan to do a couple subsequent PRs Typescript, I hope that both of those will help out with readability and conveying intent |
For precedent ember-ajax uses this pattern to make things easier for app developers. |
Conversation about this addon, this PR, and some weird ember-data behavior w/r/t the test failures: Not sure on a path forward, honestly. with ember-localforage-adapter all relationships can be sync. |
@NullVoxPopuli I don't have a Discord account. And since I have enough conversation accounts already, I am going to skip that one. What is the basic consensus regarding throwing/rejecting and or what behaviour is expected from Ember Data's perspective? I also have a question on that. The reason that I did not make the current version a stable one, is that I was doubting whether missing belongsTo relationships should fail or return null. My feeling is that the behaviour in Ember Data might have been changed since the last time I touched this codebase, which was until the beginning of this week more than one or two years I guess. |
well, around exception handling, using an exception is the right way to go always, but we learned that ember-data has some super weird behavior around rejected promises, specifically, with relationships. Here is a twiddle demonstrating the problem https://ember-twiddle.com/47e64fc2de362566b57895061b22b4b5 the current behavior in e-localforage-adapter is |
@NullVoxPopuli Ah ok. The intention of the library would be to stay in line with Ember Data. Don't forget that this code originally comes from 2014. I created it to support my app that required it. Myself I am not really up-to-date with all Ember/Ember Data developments. It could be that the addon behaves incorrectly. I did the upgrade recently to upgrade my app, and that went really well. Feel free to come up with better solutions. I am happy to merge them, as long as there are green lights. |
@frederikbosch I guess, maybe we need some help determining what intended behavior is? Say, a record from a relationship does not exist, what should happen:
|
@NullVoxPopuli Well, during the upgrade I did find out some things.
|
@frederikbosch cool, yeah -- this is certainly strange. for now, I changed me code: try {
record = await this.store.findRecord('identity', u_id);
} catch (_error) {
this.toast.error(this.intl.t('ui.chat.errors.contactNotFound'));
} and previously, it was try {
record = await this.store.findRecord('identity', u_id);
} catch (error) {
this.toast.error(error);
} the downside to this is that I'm assuming that the only reason findRecord can fail is that the record wasn't found. I assume there could be other errors, like if localforage hit a snag or something. So, we can close this PR, and work on trying to get some less troll-y behavior in ember-data, perhaps |
I think this conversation exposed two issues which are in fact seperate issues.
Since both issues provide the consumer with unexpected results (the relationship type is a fulfilled promise proxy resolved synchronously and no clear error for missing relationships) a change in the API is needed. However, a change would introduce breaking changes in current behavior and that is the conclusion of what needs to be discussed. @NullVoxPopuli, that seem about right? |
seems about right. good summary 👍 |
@sukima You are correct, in this thread multiple issues are being discussed. I just created 3 separate issues. Feel free to comment on any one of them. |
I put descriptions in all three issues, gathered from this thread. Maybe you can help resolve them before we tag 3.0 stable. |
thanks for writing those up! |
No description provided.