rx.marble.ExceptionHelper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of marbletest4j Show documentation
Show all versions of marbletest4j Show documentation
Java port of RxJS marble tests
package rx.marble;
public class ExceptionHelper {
public static String findCallerInStackTrace(Class callee) {
StackTraceElement[] stackTrace = new Exception().getStackTrace();
StackTraceElement current = null;
for (StackTraceElement element : stackTrace) {
current = element;
if (!element.getClassName().endsWith(callee.getSimpleName())
&& !element.getClassName().endsWith(ExceptionHelper.class.getSimpleName())) {
break;
}
}
return current.getClassName()
+ "." + current.getMethodName()
+ "(" + current.getFileName() + ":" + current.getLineNumber() + ")";
}
}