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

Traverson to provide more meaningful exception when link doesn't exist #539

Open
Kerruba opened this issue Feb 9, 2017 · 3 comments
Open

Comments

@Kerruba
Copy link

Kerruba commented Feb 9, 2017

At the moment an IllegalStateException is thrown when traverson doesn't find a link with the rel you specified.
What about provide a more meaningful exception, like LinkNotFoundException or similar?

@gregturn
Copy link
Contributor

The message is quite detailed:

java.lang.IllegalStateException: Expected to find link with rel 'foo' in response {
  "_links" : {
    "items" : {
      "href" : "http://localhost:52758/springagram/items{?projection}",
      "templated" : true
    },
    "profile" : {
      "href" : "http://localhost:52758/springagram/alps"
    }
  }
}
!

Are you suggesting you want to trap this type of exception across the framework? Because that sounds like an API adjustment to define a new exception for this condition.

gregturn added a commit that referenced this issue Jun 14, 2017
Instead of returning null, throw a LinkNotFoundException.

EXPERIMENTAL approach to #539
@gregturn
Copy link
Contributor

gregturn commented Jun 14, 2017

I wanted to get @olivergierke 's opinion on this. It would appear to generate a more typesafe manner of no link being found. But since this is exception handler, it also promotes using exceptions for controls.

I have attached a commit on an experimental branch.

@Kerruba
Copy link
Author

Kerruba commented Jun 20, 2017

Yeah I would say this way the exception is more context related.
Thanks

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

No branches or pull requests

2 participants