-
Notifications
You must be signed in to change notification settings - Fork 7.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement hook to render specific types in OnNextValue #2632
Conversation
FAILURE: Build failed with an exception.
|
@@ -150,6 +160,12 @@ private static String renderValue(Object value){ | |||
if (value instanceof Enum) { | |||
return ((Enum<?>) value).name(); | |||
} | |||
|
|||
String pluggedRendering = RxJavaPlugins.getInstance().getErrorHandler().handleOnNextValueRendering(value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps the ErrorHandler
should be statically referenced once at the top of this class?
* @param item the last emitted item, that caused the exception wrapped in {@link OnErrorThrowable.OnNextValue}. | ||
* @return a short {@link String} representation of the item if one is known for its type, or null for default. | ||
*/ | ||
public final String handleOnNextValueRendering(Object item) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add @Experimental
for right now during the 1.0.x release cycle?
a14b9a8
to
17ff080
Compare
thanks @benjchristensen, I've implemented your suggestions |
try { | ||
return render(item); | ||
} catch (Throwable t) { | ||
return item.getClass().getName() + ERROR_IN_RENDERING_SUFFIX; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Swallowing all Throwable
s may cause some issue. I suggest the following approach:
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
} catch (Throwable t) {
Exceptions.throwIfFatal(t);
}
return item.getClass().getName() + ERROR_IN_RENDERING_SUFFIX;
have to get back to this, I brainfailed and didn't run the whole test suite. Turns out under this condition the reset of the plugin is just ignored since we'll have cached the default implementation when first loading OnNextValue class in some previous test. @benjchristensen was this just a readability suggestion or do you think I should try to correctly reset the static reference to the plugin? |
Implement hook to render specific types in OnNextValue
awesome 😃 thanks @benjchristensen and everyone for your feedback |
as discussed in #2468, allow implementations of RxJavaErrorHandler to define a rendering behavior for safe and known types to be rendered in the stacktrace of OnNextValue.