[New] Added ExceptionHelper.getCallerMethodNoClass()

This commit is contained in:
Robert von Burg 2023-01-24 16:19:05 +01:00
parent 61ec44452a
commit 6ab6a8863f
Signed by: eitch
GPG Key ID: 75DB9C85C74331F7
1 changed files with 8 additions and 1 deletions

View File

@ -41,7 +41,14 @@ public class ExceptionHelper {
public static String getCallerMethod(int depth) {
return StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE) //
.walk(frames -> frames.map((StackWalker.StackFrame sf) -> sf.getClassName() + "." + sf.getMethodName())
.skip(depth).findFirst()).orElse("UnknownClass.unknownMethod!");
.skip(depth)
.findFirst()).orElse("UnknownClass.unknownMethod!");
}
public static String getCallerMethodNoClass(int depth) {
return StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE) //
.walk(frames -> frames.map(StackWalker.StackFrame::getMethodName).skip(depth).findFirst())
.orElse("UnknownClass.unknownMethod!");
}
/**