2020-04-02 23:07:06 +02:00
|
|
|
From d7f401b6507cf6813a6e17cd0ad3df6d35d3a9e7 Mon Sep 17 00:00:00 2001
|
2019-02-23 18:17:41 +01:00
|
|
|
From: Aikar <aikar@aikar.co>
|
|
|
|
Date: Sat, 23 Feb 2019 11:26:21 -0500
|
|
|
|
Subject: [PATCH] Paper Utils
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/com/destroystokyo/paper/util/SneakyThrow.java b/src/main/java/com/destroystokyo/paper/util/SneakyThrow.java
|
|
|
|
new file mode 100644
|
2020-04-02 23:07:06 +02:00
|
|
|
index 000000000..9db0056ab
|
2019-02-23 18:17:41 +01:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/util/SneakyThrow.java
|
2019-03-20 01:28:15 +01:00
|
|
|
@@ -0,0 +1,16 @@
|
2019-02-23 18:17:41 +01:00
|
|
|
+package com.destroystokyo.paper.util;
|
|
|
|
+
|
2019-03-20 01:28:15 +01:00
|
|
|
+import org.jetbrains.annotations.NotNull;
|
|
|
|
+
|
2019-02-23 18:17:41 +01:00
|
|
|
+public class SneakyThrow {
|
|
|
|
+
|
2019-03-20 01:28:15 +01:00
|
|
|
+ public static void sneaky(@NotNull Throwable exception) {
|
2019-02-23 18:17:41 +01:00
|
|
|
+ SneakyThrow.<RuntimeException>throwSneaky(exception);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @SuppressWarnings("unchecked")
|
2019-03-20 01:28:15 +01:00
|
|
|
+ private static <T extends Throwable> void throwSneaky(@NotNull Throwable exception) throws T {
|
2019-02-23 18:17:41 +01:00
|
|
|
+ throw (T) exception;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
--
|
2020-04-02 23:07:06 +02:00
|
|
|
2.25.1
|
2019-02-23 18:17:41 +01:00
|
|
|
|