[
https://issues.apache.org/jira/browse/FLINK-5854?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15874916#comment-15874916
]
ASF GitHub Bot commented on FLINK-5854:
---------------------------------------
Github user zentol commented on a diff in the pull request:
https://github.com/apache/flink/pull/3368#discussion_r102072425
--- Diff:
flink-core/src/main/java/org/apache/flink/util/DynamicCodeLoadingException.java
---
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.util;
+
+import org.apache.flink.annotation.Public;
+
+/**
+ * An exception that is thrown if the dynamic instantiation of code fails.
+ *
+ * <p>This exception is supposed to "sum up" the zoo of exceptions
typically thrown around
+ * dynamic code loading and instantiations:
+ *
+ * <pre>{@code
+ * try {
+ * Class.forName(classname).asSubclass(TheType.class).newInstance();
+ * }
+ * catch (ClassNotFoundException | ClassCastException |
InstantiationException | IllegalAccessException e) {
+ * throw new DynamicCodeLoadingException(e);
+ * }
+ * }</pre>
+ */
+@Public
+public class DynamicCodeLoadingException extends FlinkException {
+
+ private static final long serialVersionUID = -25138443817255490L;
+
+ /**
+ * Creates a new exception with the given message and cause
+ *
+ * @param message The exception message
+ * @param cause The exception that caused this exception
+ */
+ public DynamicCodeLoadingException(String message, Throwable cause) {
--- End diff --
Would it make sense to make this constructor more explicit in the type of
exceptions it accepts? (i.e. one constructor each for the exceptions that are
typically thrown in situations that we want to cover)
It's probably just be bloat, but maybe it would prevent misuse of this
exception.
> 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)