Skip to content

Instantly share code, notes, and snippets.

@vivekgidmare
Forked from dlew/File.java
Created April 7, 2016 16:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vivekgidmare/e94936aff3f37fae4aba9ceabbbd54e2 to your computer and use it in GitHub Desktop.
Save vivekgidmare/e94936aff3f37fae4aba9ceabbbd54e2 to your computer and use it in GitHub Desktop.
Automated onError() message generation
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