Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Java spring throw exceptions (#5686) #5738

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

Merged

Conversation

@stevecookform3
Copy link
Contributor

@stevecookform3 stevecookform3 commented May 30, 2017

PR checklist

  • Read the contribution guidelines.
  • Ran the shell/batch script under ./bin/ to update Petstore sample so that CIs can verify the change. (For instance, only need to run ./bin/{LANG}-petstore.sh and ./bin/security/{LANG}-petstore.sh if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates)
  • Filed the PR against the correct branch: master for non-breaking changes and 2.3.0 branch for breaking (non-backward compatible) changes.

Description of the PR

Adds 'throws Exception' to all controller methods. This allows servers to implement global exception handling in Spring, where controller methods can throw exceptions and have them handled globally.

Breaking change, hence filed against 2.3.0

See Issue #5686

Copy link
Contributor

wing328 commented May 31, 2017

@stevecookform3 your PR contains 2 commits not belonging to you.

I would suggest you to rebase the change on the latest 2.3.0 so as to resolve the merge conflicts (or file a new one based on the latest 2.3.0)

Copy link
Contributor Author

@wing328 i've rebased to 2.3.0. can you take another look? thanks..

Copy link
Contributor Author

@wing328 sorry let me fix the commit and test first

Copy link
Contributor

wing328 commented May 31, 2017

@stevecookform3 no worry. Please take your time and let us know if you need any help.

Most importantly, thanks for the enhancement 👍

Copy link
Contributor Author

@wing328 fixed. can you take a look?

@wing328 wing328 merged commit b185d03 into swagger-api:2.3.0 Jun 11, 2017
Copy link
Contributor

wing328 commented Jun 11, 2017

@stevecookform3 I've resolved the merge conflicts and merged your PR into 2.3.0 Please pull the latest to have a look. Thanks.

Copy link
Contributor

cbornet commented Oct 27, 2017

Oh, too late it seems.
I think throwing Exception in interfaces is a bad pattern : it defeats the checked exception pattern and is just like using Object in your methods.
Checked exceptions should be handled in the implementations and if you want external handling (eg. ControllerAdvice/ExceptionHandler), you can rethrow runtime exceptions.

Bols reacted with thumbs up emoji

Copy link
Contributor

wing328 commented Nov 22, 2017

@cbornet well never too later to voice out :). Do you mind opening a new issue to start the discussion?

Other server generators (e.g. Nancyfx) may need similar debate later so maybe we need a CLI option to cater both?

Copy link
Contributor

Bols commented Jan 11, 2018

Global exception handling is generally not the right approach, and by default the generation should definitely NOT throw Exception. If anything, this should be a configurable option for those few that still use global exception handling.
Not all breaking changes are good changes... :-)

luzzif reacted with thumbs down emoji

Copy link
Contributor

wing328 commented Jan 14, 2018

@Bols Understood that not everyone likes global exception handling. Do you mind contributing the configurable option for this?

Copy link
Contributor

Bols commented Jan 22, 2018 via email

Jarle (who is sitting a couple of desks away) has fixed this now, right? - Trond
...
On Sun, Jan 14, 2018 at 4:49 PM, William Cheng ***@***.***> wrote: @Bols <https://github.com/bols> Understood that not everyone likes global exception handling. Do you mind contributing the configurable option for this? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#5738 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AAIBsFr-LdxaigJ6bDeTrssr29VLqOMEks5tKiIagaJpZM4NqjbC> .

Copy link
Contributor

wing328 commented Jan 22, 2018

@Bols yup, please pull the latest master to give it a try.

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

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

v2.2.3

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /