-
-
Save semanticer/863b860b3e0cd6c90ff2e94c31818442 to your computer and use it in GitHub Desktop.
Automated onError() message generation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static Action1<Throwable> crashOnError() { | |
final Throwable checkpoint = new Throwable(); | |
return throwable -> { | |
StackTraceElement[] stackTrace = checkpoint.getStackTrace(); | |
StackTraceElement element = stackTrace[1]; // First element after `crashOnError()` | |
String msg = String.format("onError() crash from subscribe() in %s.%s(%s:%s)", | |
element.getClassName(), | |
element.getMethodName(), | |
element.getFileName(), | |
element.getLineNumber()); | |
throw new OnErrorNotImplementedException(msg, throwable); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment