[ 
https://issues.apache.org/jira/browse/FLINK-5854?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15874933#comment-15874933
 ] 

ASF GitHub Bot commented on FLINK-5854:
---------------------------------------

Github user StephanEwen commented on the issue:

    https://github.com/apache/flink/pull/3368
  
    @zentol There are many places in the runtime that declare `throws 
Exception`, for example virtually all of the state handling code. This always 
came from the desire to throw `IOException` plus something that expresses that 
non-I/O stuff related to Flink went wrong. The result was a `throws Exception`, 
which also means that you have to catch `Exception` which you often don't want 
(because this included `RuntimeException` and you typically want runtime 
exception to bubble up a bit further, since they denote bugs by encouraged 
design).
    
    The only place where `throws Exception` really makes sense to me is for 
`MapFunction` and the likes, to allow them to propagate any type of exception 
and let recovery handle them.


> Introduce some Flink-specific base Exception types
> --------------------------------------------------
>
>                 Key: FLINK-5854
>                 URL: https://issues.apache.org/jira/browse/FLINK-5854
>             Project: Flink
>          Issue Type: Improvement
>          Components: Core
>            Reporter: Stephan Ewen
>            Assignee: Stephan Ewen
>             Fix For: 1.3.0
>
>
> Going through the code, there are a lot of places where exception handling 
> could be done a bit nicer, for example 
>   - Some methods do not declare exceptions at all in their signatures. They 
> simply catch all and wrap it in a {{RuntimeException}}.
>   - Some places declare overly generic that they throw {{Exception}}, even 
> though they could very specifically type the exceptions they throw.
> I suggest to introduce two new basic exceptions, that at least help document 
> a bit more what goes wrong:
>   - {{FlinkException}} as a base class for checked exceptions that indicate 
> that something related to using Flink went wrong. Letting a method throw 
> {{FlinkException}} rather than {{Exception}} already helps to not include all 
> of Java's runtime exceptions, which indicate programming errors, rather than 
> situations that should be recovered.
>   - {{FlinkUncheckedException}} as a Flink-specific subclass of 
> {{RuntimeException}}. That one can come in handy in places where no 
> exceptions were declared, for example when reusing an interface that does not 
> declare exceptions.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to