summaryrefslogtreecommitdiff
path: root/src/main/java/ftbsc/lll/exceptions
diff options
context:
space:
mode:
author zaaarf <zaaarf@proton.me>2023-03-18 17:24:43 +0100
committer zaaarf <zaaarf@proton.me>2023-03-18 17:24:43 +0100
commit344e66061b31a83f7ace2ab887e80f782f560297 (patch)
treeb8841cdf15a97376cc75206818a989b0e1918e36 /src/main/java/ftbsc/lll/exceptions
parent8695612c58141b1d5e0ee274027ebbd2050de6f8 (diff)
parent909f5cfa07464f35814da1686b0ac1a6c3ea03dd (diff)
Merge branch 'version3' into dev
Diffstat (limited to 'src/main/java/ftbsc/lll/exceptions')
-rw-r--r--src/main/java/ftbsc/lll/exceptions/AmbiguousDefinitionException.java25
-rw-r--r--src/main/java/ftbsc/lll/exceptions/InvalidResourceException.java22
-rw-r--r--src/main/java/ftbsc/lll/exceptions/MappingNotFoundException.java27
-rw-r--r--src/main/java/ftbsc/lll/exceptions/TargetNotFoundException.java15
4 files changed, 89 insertions, 0 deletions
diff --git a/src/main/java/ftbsc/lll/exceptions/AmbiguousDefinitionException.java b/src/main/java/ftbsc/lll/exceptions/AmbiguousDefinitionException.java
new file mode 100644
index 0000000..1befaa8
--- /dev/null
+++ b/src/main/java/ftbsc/lll/exceptions/AmbiguousDefinitionException.java
@@ -0,0 +1,25 @@
+package ftbsc.lll.exceptions;
+
+/**
+ * Thrown when the processor finds multiple methods matching the
+ * given criteria.
+ */
+public class AmbiguousDefinitionException extends RuntimeException {
+
+ /**
+ * Constructs a new ambiguous definition exception with the specified detail message.
+ * @param message the detail message
+ */
+ public AmbiguousDefinitionException(String message) {
+ super(message);
+ }
+
+ /**
+ * Constructs a new ambiguous definition exception with the specified detail message and cause.
+ * @param message the detail message
+ * @param cause the cause, may be null (indicating nonexistent or unknown cause)
+ */
+ public AmbiguousDefinitionException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/src/main/java/ftbsc/lll/exceptions/InvalidResourceException.java b/src/main/java/ftbsc/lll/exceptions/InvalidResourceException.java
new file mode 100644
index 0000000..76f12a5
--- /dev/null
+++ b/src/main/java/ftbsc/lll/exceptions/InvalidResourceException.java
@@ -0,0 +1,22 @@
+package ftbsc.lll.exceptions;
+
+/**
+ * Thrown when a resource passed as an argument is not found.
+ */
+public class InvalidResourceException extends RuntimeException {
+
+ /**
+ * Empty constructor, used when the provided resource exists but is empty.
+ */
+ public InvalidResourceException() {
+ super("The specified resource was empty!");
+ }
+
+ /**
+ * Named constructor, used when the specified resource doesn't exist.
+ * @param name the resource name
+ */
+ public InvalidResourceException(String name) {
+ super(String.format("Specified resource %s was not found!", name));
+ }
+}
diff --git a/src/main/java/ftbsc/lll/exceptions/MappingNotFoundException.java b/src/main/java/ftbsc/lll/exceptions/MappingNotFoundException.java
new file mode 100644
index 0000000..e943c01
--- /dev/null
+++ b/src/main/java/ftbsc/lll/exceptions/MappingNotFoundException.java
@@ -0,0 +1,27 @@
+package ftbsc.lll.exceptions;
+
+import ftbsc.lll.processor.tools.obfuscation.ObfuscationMapper;
+
+/**
+ * Thrown upon failure to find the requested mapping within a loaded {@link ObfuscationMapper}.
+ */
+public class MappingNotFoundException extends RuntimeException {
+
+ /**
+ * Constructs a new mapping not found exception for the specified mapping.
+ * @param mapping the relevant mapping
+ */
+ public MappingNotFoundException(String mapping) {
+ super(String.format("Could not find mapping for %s!", mapping));
+ }
+
+ /**
+ * Constructs a new mapping not found exception for the specified mapping
+ * with the specified reason.
+ * @param mapping the relevant mapping
+ * @param reason the reason message
+ */
+ public MappingNotFoundException(String mapping, String reason) {
+ this(mapping + ": " + reason);
+ }
+}
diff --git a/src/main/java/ftbsc/lll/exceptions/TargetNotFoundException.java b/src/main/java/ftbsc/lll/exceptions/TargetNotFoundException.java
new file mode 100644
index 0000000..c82e0fc
--- /dev/null
+++ b/src/main/java/ftbsc/lll/exceptions/TargetNotFoundException.java
@@ -0,0 +1,15 @@
+package ftbsc.lll.exceptions;
+
+/**
+ * Thrown upon failure to find an existing method from a stub.
+ */
+public class TargetNotFoundException extends RuntimeException {
+
+ /**
+ * Constructs a new target not found exception for the specified method stub.
+ * @param stub the stub's name (and descriptor possibly)
+ */
+ public TargetNotFoundException(String stub) {
+ super(String.format("Could not find member corresponding to stub: %s.", stub));
+ }
+}