takes: Handling non-IOExceptions in Take is broken
Take interface expects to throw IOException. This is limiting. In my Take implementations I often make SQL calls or JSON manipulations which throw checked SQLException or checked JsonException.
Why Take cannot throw Exception, instead? Especially, as in the blog I can read “use only Exception, without any sub-types.”.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 3
- Comments: 25 (21 by maintainers)
Commits related to this issue
- #872 Take throws Exception — committed to piotrkot/takes by piotrkot 5 years ago
@piotrkot @fabriciofx OK, OK, you got me. I agree, let’s do
throws Exception.First of all, Merry Christmas and Happy New Year to everyone! 😃
@yegor256 Please, explain why you think so. Let me share some thoughts. Takes is a web framework. Unlike in libraries, you expect/invite users to put their logic (business logic) into your code skeleton. Here, you want them to make new implementations of
org.takes.Takeinterface. I makeTakeimplementations that send emails, call external services, persist data in storage systems, etc. All such implementations throw different checked exceptions. Why do I have to wrap each exception intoIOException? Why did you decide to useIOExceptionas a general type exception? From your blog I see you are an advocate of using generalExceptionclass, aren’t you? As you are already catchingExceptioninBkBasicandTkFallback, why don’t you let it throw in general purposeTakeimplementations?