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

Most upvoted comments

@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.Take interface. I make Take implementations 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 into IOException? Why did you decide to use IOException as a general type exception? From your blog I see you are an advocate of using general Exception class, aren’t you? As you are already catching Exception in BkBasic and TkFallback, why don’t you let it throw in general purpose Take implementations?