From 3d131b972e1e051f18d5233057ce760aa685c3b0 Mon Sep 17 00:00:00 2001 From: Alexander Verbraeck Date: Fri, 1 Nov 2024 23:02:56 +0100 Subject: [PATCH] Potential new exceptions with more clear names. --- .../djutils/draw/DegenerateLineException.java | 54 +++++++++++++++++++ .../draw/InternalCalculationException.java | 54 +++++++++++++++++++ .../draw/InvalidProjectionException.java | 54 +++++++++++++++++++ 3 files changed, 162 insertions(+) create mode 100644 djutils-draw/src/main/java/org/djutils/draw/DegenerateLineException.java create mode 100644 djutils-draw/src/main/java/org/djutils/draw/InternalCalculationException.java create mode 100644 djutils-draw/src/main/java/org/djutils/draw/InvalidProjectionException.java diff --git a/djutils-draw/src/main/java/org/djutils/draw/DegenerateLineException.java b/djutils-draw/src/main/java/org/djutils/draw/DegenerateLineException.java new file mode 100644 index 00000000..26679f32 --- /dev/null +++ b/djutils-draw/src/main/java/org/djutils/draw/DegenerateLineException.java @@ -0,0 +1,54 @@ +package org.djutils.draw; + +/** + * DegenerateLineException is a special type of DrawRuntimeException, that is thrown if a line or line segment is constructed or + * simplified to less than two points. + *

+ * Copyright (c) 2020-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
+ * BSD-style license. See DJUTILS License. + *

+ * @author Alexander Verbraeck + * @author Peter Knoppers + */ +public class DegenerateLineException extends DrawRuntimeException +{ + /** */ + private static final long serialVersionUID = 20200828L; + + /** + * Create an empty runtime drawing exception. + */ + public DegenerateLineException() + { + super(); + } + + /** + * Create a runtime drawing exception with a custom message. + * @param message String; the custom message. + */ + public DegenerateLineException(final String message) + { + super(message); + } + + /** + * Create a runtime drawing exception with an underlying cause. + * @param cause Throwable; the cause of this exception to be thrown + */ + public DegenerateLineException(final Throwable cause) + { + super(cause); + } + + /** + * Create a runtime drawing exception with a custom message and an underlying cause. + * @param message String; the custom message + * @param cause Throwable; the cause of this exception to be thrown + */ + public DegenerateLineException(final String message, final Throwable cause) + { + super(message, cause); + } + +} diff --git a/djutils-draw/src/main/java/org/djutils/draw/InternalCalculationException.java b/djutils-draw/src/main/java/org/djutils/draw/InternalCalculationException.java new file mode 100644 index 00000000..1634063f --- /dev/null +++ b/djutils-draw/src/main/java/org/djutils/draw/InternalCalculationException.java @@ -0,0 +1,54 @@ +package org.djutils.draw; + +/** + * InternalCalculationException is a special type of DrawRuntimeException, that is thrown if a method fails during the + * construction of a drawable object or during the calculation of a property of a drawable object. + *

+ * Copyright (c) 2020-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
+ * BSD-style license. See DJUTILS License. + *

+ * @author Alexander Verbraeck + * @author Peter Knoppers + */ +public class InternalCalculationException extends DrawRuntimeException +{ + /** */ + private static final long serialVersionUID = 20200828L; + + /** + * Create an empty runtime drawing exception. + */ + public InternalCalculationException() + { + super(); + } + + /** + * Create a runtime drawing exception with a custom message. + * @param message String; the custom message. + */ + public InternalCalculationException(final String message) + { + super(message); + } + + /** + * Create a runtime drawing exception with an underlying cause. + * @param cause Throwable; the cause of this exception to be thrown + */ + public InternalCalculationException(final Throwable cause) + { + super(cause); + } + + /** + * Create a runtime drawing exception with a custom message and an underlying cause. + * @param message String; the custom message + * @param cause Throwable; the cause of this exception to be thrown + */ + public InternalCalculationException(final String message, final Throwable cause) + { + super(message, cause); + } + +} diff --git a/djutils-draw/src/main/java/org/djutils/draw/InvalidProjectionException.java b/djutils-draw/src/main/java/org/djutils/draw/InvalidProjectionException.java new file mode 100644 index 00000000..e80e7f6d --- /dev/null +++ b/djutils-draw/src/main/java/org/djutils/draw/InvalidProjectionException.java @@ -0,0 +1,54 @@ +package org.djutils.draw; + +/** + * InvalidProjectionException is a special type of DrawRuntimeException, that is thrown if a projection results in an invalid + * object, or if a projection cannot be carried out. + *

+ * Copyright (c) 2020-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
+ * BSD-style license. See DJUTILS License. + *

+ * @author Alexander Verbraeck + * @author Peter Knoppers + */ +public class InvalidProjectionException extends DrawRuntimeException +{ + /** */ + private static final long serialVersionUID = 20200828L; + + /** + * Create an empty runtime drawing exception. + */ + public InvalidProjectionException() + { + super(); + } + + /** + * Create a runtime drawing exception with a custom message. + * @param message String; the custom message. + */ + public InvalidProjectionException(final String message) + { + super(message); + } + + /** + * Create a runtime drawing exception with an underlying cause. + * @param cause Throwable; the cause of this exception to be thrown + */ + public InvalidProjectionException(final Throwable cause) + { + super(cause); + } + + /** + * Create a runtime drawing exception with a custom message and an underlying cause. + * @param message String; the custom message + * @param cause Throwable; the cause of this exception to be thrown + */ + public InvalidProjectionException(final String message, final Throwable cause) + { + super(message, cause); + } + +}