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

Remove ResourceNotFoundException #24

Closed
mreichelt opened this issue Sep 22, 2016 · 4 comments
Closed

Remove ResourceNotFoundException #24

mreichelt opened this issue Sep 22, 2016 · 4 comments

Comments

@mreichelt
Copy link
Contributor

Instead of using ResourceNotFoundException I suggest we should simply return null instead.
Reasons:

  • The check against null is pretty common for developers.
  • IDEs have built-in support for methods returning null.
  • Null is a common use case for jsonapi – common use cases should not throw exceptions.
  • This would also solve Add support for finding if a HasOne and HasMany contains data #12 in a jiffy – finding this info is a null check. :)
@kamikat
Copy link
Owner

kamikat commented Sep 23, 2016

When a ResourceNotFoundException thrown from get() it means that the referenced resource is not provided by Document or there is not document related with current Resource object. When there is a null value of a relationship the value of HasOne<>/HasMany<> should be null, and there's no matter with ResourceNotFoundException.

@kamikat
Copy link
Owner

kamikat commented Sep 23, 2016

UPDATE I've update the document. We're now returning null when HasOne/HasMany cannot found resources. ResourceNotFoundException is reserved for Document.find(String, String)

@kamikat kamikat closed this as completed Sep 23, 2016
@mreichelt
Copy link
Contributor Author

@kamikat Thanks!
Document.find(String, String) is a good example for my case: It should behave nearly like a Map in Java – which returns null if a value can not be found.

@mreichelt
Copy link
Contributor Author

mreichelt commented Sep 23, 2016

@kamikat I added PR #25 for a simple merge-and-be-happy if you like the change. :)

kamikat added a commit that referenced this issue Nov 30, 2016
…xception

fix #24 remove ResourceNotFoundException
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