From 9ecf49696925364886070d6d3ac30c9fa6bf9b2f Mon Sep 17 00:00:00 2001 From: Tyler Veness Date: Tue, 27 Feb 2024 12:35:39 -0800 Subject: [PATCH] Remove unused exception classes (#109) We don't throw them anywhere, so there's no reason to catch them. --- examples/Swerve/src/Main.cpp | 1 - .../trajopt/IncompatibleTrajectoryException.h | 34 ------------------- include/trajopt/InvalidPathException.h | 32 ----------------- .../trajopt/InvalidPathException.java | 9 ----- .../trajopt/OptimalTrajectoryGenerator.java | 4 +-- jni/TrajoptLibJNI.cpp | 5 --- src/IncompatibleTrajectoryException.cpp | 14 -------- src/InvalidPathException.cpp | 12 ------- src/OptimalTrajectoryGenerator.cpp | 1 - 9 files changed, 2 insertions(+), 110 deletions(-) delete mode 100644 include/trajopt/IncompatibleTrajectoryException.h delete mode 100644 include/trajopt/InvalidPathException.h delete mode 100644 java/src/main/java/org/sleipnirgroup/trajopt/InvalidPathException.java delete mode 100644 src/IncompatibleTrajectoryException.cpp delete mode 100644 src/InvalidPathException.cpp diff --git a/examples/Swerve/src/Main.cpp b/examples/Swerve/src/Main.cpp index 750f18fb..39368d73 100644 --- a/examples/Swerve/src/Main.cpp +++ b/examples/Swerve/src/Main.cpp @@ -5,7 +5,6 @@ #include #include -#include #include #include #include diff --git a/include/trajopt/IncompatibleTrajectoryException.h b/include/trajopt/IncompatibleTrajectoryException.h deleted file mode 100644 index 9e439aef..00000000 --- a/include/trajopt/IncompatibleTrajectoryException.h +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (c) TrajoptLib contributors - -#pragma once - -#include -#include - -#include "trajopt/SymbolExports.h" - -namespace trajopt { - -/** - * Incompatible trajectory exception. - */ -class TRAJOPT_DLLEXPORT IncompatibleTrajectoryException - : public std::logic_error { - public: - /** - * Construct a new IncompatibleTrajectoryException object with a string - * message - * - * @param message the message - */ - explicit IncompatibleTrajectoryException(const std::string& message); - - /** - * Construct a new IncompatibleTrajectoryException object with a string - * message - * - * @param message the message - */ - explicit IncompatibleTrajectoryException(const char* message); -}; -} // namespace trajopt diff --git a/include/trajopt/InvalidPathException.h b/include/trajopt/InvalidPathException.h deleted file mode 100644 index f1e8af46..00000000 --- a/include/trajopt/InvalidPathException.h +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) TrajoptLib contributors - -#pragma once - -#include -#include - -#include "trajopt/SymbolExports.h" - -namespace trajopt { - -/** - * @brief This exception is thrown when an invalid path is used with a - * trajectory generator. - */ -class TRAJOPT_DLLEXPORT InvalidPathException : public std::logic_error { - public: - /** - * @brief Construct a new InvalidPathException object with a string message - * - * @param message the message - */ - explicit InvalidPathException(const std::string& message); - - /** - * @brief Construct a new InvalidPathException object with a string message - * - * @param message the message - */ - explicit InvalidPathException(const char* message); -}; -} // namespace trajopt diff --git a/java/src/main/java/org/sleipnirgroup/trajopt/InvalidPathException.java b/java/src/main/java/org/sleipnirgroup/trajopt/InvalidPathException.java deleted file mode 100644 index a7a5b685..00000000 --- a/java/src/main/java/org/sleipnirgroup/trajopt/InvalidPathException.java +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright (c) TrajoptLib contributors - -package org.sleipnirgroup.trajopt; - -public class InvalidPathException extends Exception { - public InvalidPathException(String message) { - super(message); - } -} diff --git a/java/src/main/java/org/sleipnirgroup/trajopt/OptimalTrajectoryGenerator.java b/java/src/main/java/org/sleipnirgroup/trajopt/OptimalTrajectoryGenerator.java index 7acbcdb6..014fda2b 100644 --- a/java/src/main/java/org/sleipnirgroup/trajopt/OptimalTrajectoryGenerator.java +++ b/java/src/main/java/org/sleipnirgroup/trajopt/OptimalTrajectoryGenerator.java @@ -8,10 +8,10 @@ public final class OptimalTrajectoryGenerator { private native HolonomicTrajectory generateHolonomicTrajectory(SwerveDrivetrain swerveDrivetrain, - HolonomicPath holonomicPath) throws InvalidPathException, TrajectoryGenerationException; + HolonomicPath holonomicPath) throws TrajectoryGenerationException; public static HolonomicTrajectory generate(SwerveDrivetrain swerveDrivetrain, HolonomicPath holonomicPath) - throws NullPointerException, InvalidPathException, PluginLoadException, TrajectoryGenerationException { + throws NullPointerException, PluginLoadException, TrajectoryGenerationException { PluginLoader.loadPlugin(); return new OptimalTrajectoryGenerator().generateHolonomicTrajectory( Objects.requireNonNull(swerveDrivetrain, "Holonomic Trajectory Generator swerve drivetrain cannot be null"), diff --git a/jni/TrajoptLibJNI.cpp b/jni/TrajoptLibJNI.cpp index 1a3cad44..8644b7b9 100644 --- a/jni/TrajoptLibJNI.cpp +++ b/jni/TrajoptLibJNI.cpp @@ -7,7 +7,6 @@ #include "jni.h" #include "org_sleipnirgroup_trajopt_OptimalTrajectoryGenerator.h" -#include "trajopt/InvalidPathException.h" #include "trajopt/OptimalTrajectoryGenerator.h" #include "trajopt/TrajectoryGenerationException.h" #include "trajopt/constraint/AngularVelocityConstraint.h" @@ -459,10 +458,6 @@ Java_org_sleipnirgroup_trajopt_OptimalTrajectoryGenerator_generateHolonomicTraje auto solution = OptimalTrajectoryGenerator::Generate(path); auto trajectory = HolonomicTrajectory(solution); return jHolonomicTrajectoryFromHolonomicTrajectory(env, trajectory); - } catch (const InvalidPathException& e) { - jclass jInvalidPathExceptionClass = - env->FindClass("org/sleipnirgroup/trajopt/InvalidPathException"); - env->ThrowNew(jInvalidPathExceptionClass, e.what()); return nullptr; } catch (const TrajectoryGenerationException& e) { jclass jTrajectoryGenerationExceptionClass = env->FindClass( diff --git a/src/IncompatibleTrajectoryException.cpp b/src/IncompatibleTrajectoryException.cpp deleted file mode 100644 index b8a80f4c..00000000 --- a/src/IncompatibleTrajectoryException.cpp +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (c) TrajoptLib contributors - -#include "trajopt/IncompatibleTrajectoryException.h" - -namespace trajopt { - -IncompatibleTrajectoryException::IncompatibleTrajectoryException( - const std::string& message) - : std::logic_error(message) {} - -IncompatibleTrajectoryException::IncompatibleTrajectoryException( - const char* message) - : std::logic_error(message) {} -} // namespace trajopt diff --git a/src/InvalidPathException.cpp b/src/InvalidPathException.cpp deleted file mode 100644 index a837424a..00000000 --- a/src/InvalidPathException.cpp +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (c) TrajoptLib contributors - -#include "trajopt/InvalidPathException.h" - -namespace trajopt { - -InvalidPathException::InvalidPathException(const std::string& message) - : std::logic_error(message) {} - -InvalidPathException::InvalidPathException(const char* message) - : std::logic_error(message) {} -} // namespace trajopt diff --git a/src/OptimalTrajectoryGenerator.cpp b/src/OptimalTrajectoryGenerator.cpp index aa47fc64..ba3ce070 100644 --- a/src/OptimalTrajectoryGenerator.cpp +++ b/src/OptimalTrajectoryGenerator.cpp @@ -12,7 +12,6 @@ #define _OPTI_BACKEND SleipnirExpr, SleipnirOpti #endif #include "DebugOptions.h" -#include "trajopt/InvalidPathException.h" #include "trajopt/drivetrain/SwerveDrivetrain.h" #include "optimization/algorithms/SwerveDiscreteOptimal.h" #include "trajopt/solution/SwerveSolution.h"