[FLINK-5854] [core] Add base Flink Exception classes This closes #3368
Project: http://git-wip-us.apache.org/repos/asf/flink/repo Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/813c2585 Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/813c2585 Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/813c2585 Branch: refs/heads/master Commit: 813c2585a49c673b71678463d719b6a85b778994 Parents: 31f3d65 Author: Stephan Ewen <[email protected]> Authored: Fri Feb 17 16:24:35 2017 +0100 Committer: Stephan Ewen <[email protected]> Committed: Fri Feb 24 12:15:18 2017 +0100 ---------------------------------------------------------------------- .../flink/util/DynamicCodeLoadingException.java | 61 ++++++++++++++++++++ .../org/apache/flink/util/FlinkException.java | 58 +++++++++++++++++++ .../flink/util/FlinkRuntimeException.java | 58 +++++++++++++++++++ 3 files changed, 177 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flink/blob/813c2585/flink-core/src/main/java/org/apache/flink/util/DynamicCodeLoadingException.java ---------------------------------------------------------------------- diff --git a/flink-core/src/main/java/org/apache/flink/util/DynamicCodeLoadingException.java b/flink-core/src/main/java/org/apache/flink/util/DynamicCodeLoadingException.java new file mode 100644 index 0000000..d18b9d3 --- /dev/null +++ b/flink-core/src/main/java/org/apache/flink/util/DynamicCodeLoadingException.java @@ -0,0 +1,61 @@ +/* + * 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("Could not load and instantiate " + classname", e); + * } + * }</pre> + */ +@Public +public class DynamicCodeLoadingException extends FlinkException { + + private static final long serialVersionUID = -25138443817255490L; + + /** + * Creates a new exception with the given cause. + * + * @param cause The exception that caused this exception + */ + public DynamicCodeLoadingException(Throwable cause) { + super(cause); + } + + /** + * 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) { + super(message, cause); + } +} http://git-wip-us.apache.org/repos/asf/flink/blob/813c2585/flink-core/src/main/java/org/apache/flink/util/FlinkException.java ---------------------------------------------------------------------- diff --git a/flink-core/src/main/java/org/apache/flink/util/FlinkException.java b/flink-core/src/main/java/org/apache/flink/util/FlinkException.java new file mode 100644 index 0000000..550ab2c --- /dev/null +++ b/flink-core/src/main/java/org/apache/flink/util/FlinkException.java @@ -0,0 +1,58 @@ +/* + * 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; + +/** + * Base class of all Flink-specific checked exceptions. + */ +@Public +public class FlinkException extends Exception { + + private static final long serialVersionUID = 450688772469004724L; + + /** + * Creates a new Exception with the given message and null as the cause. + * + * @param message The exception message + */ + public FlinkException(String message) { + super(message); + } + + /** + * Creates a new exception with a null message and the given cause. + * + * @param cause The exception that caused this exception + */ + public FlinkException(Throwable cause) { + super(cause); + } + + /** + * Creates a new exception with the given message and cause + * + * @param message The exception message + * @param cause The exception that caused this exception + */ + public FlinkException(String message, Throwable cause) { + super(message, cause); + } +} http://git-wip-us.apache.org/repos/asf/flink/blob/813c2585/flink-core/src/main/java/org/apache/flink/util/FlinkRuntimeException.java ---------------------------------------------------------------------- diff --git a/flink-core/src/main/java/org/apache/flink/util/FlinkRuntimeException.java b/flink-core/src/main/java/org/apache/flink/util/FlinkRuntimeException.java new file mode 100644 index 0000000..16b783b --- /dev/null +++ b/flink-core/src/main/java/org/apache/flink/util/FlinkRuntimeException.java @@ -0,0 +1,58 @@ +/* + * 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; + +/** + * Base class of all Flink-specific unchecked exceptions. + */ +@Public +public class FlinkRuntimeException extends RuntimeException { + + private static final long serialVersionUID = 193141189399279147L; + + /** + * Creates a new Exception with the given message and null as the cause. + * + * @param message The exception message + */ + public FlinkRuntimeException(String message) { + super(message); + } + + /** + * Creates a new exception with a null message and the given cause. + * + * @param cause The exception that caused this exception + */ + public FlinkRuntimeException(Throwable cause) { + super(cause); + } + + /** + * Creates a new exception with the given message and cause + * + * @param message The exception message + * @param cause The exception that caused this exception + */ + public FlinkRuntimeException(String message, Throwable cause) { + super(message, cause); + } +}
