From 6adb3bf2c1af9d6b507b1385f0f41f35f6b5be3b Mon Sep 17 00:00:00 2001 From: Robert von Burg Date: Thu, 27 Feb 2020 11:51:23 +0100 Subject: [PATCH] [New] Added ExceptionHelper.getCallerMethod() --- .../java/li/strolch/utils/helper/ExceptionHelper.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/li.strolch.utils/src/main/java/li/strolch/utils/helper/ExceptionHelper.java b/li.strolch.utils/src/main/java/li/strolch/utils/helper/ExceptionHelper.java index 5c0c0371f..7957f9224 100644 --- a/li.strolch.utils/src/main/java/li/strolch/utils/helper/ExceptionHelper.java +++ b/li.strolch.utils/src/main/java/li/strolch/utils/helper/ExceptionHelper.java @@ -29,6 +29,16 @@ import li.strolch.utils.RemoveCRFilterWriter; */ public class ExceptionHelper { + /** + * Returns the class name and method name of the caller + * + * @return the class name and method name of the caller + */ + public static String getCallerMethod() { + StackTraceElement element = new Throwable().getStackTrace()[1]; + return element.getClassName() + "." + element.getMethodName(); + } + /** *

* Returns a message for the given {@link Throwable}