ErrorParser extends Tag<Throwable> { static String parse(Throwable error) { if (error == null) throw new NullPointerException("error == null"); String message = error.getMessage(); if (message != null) return message; if (error.getClass().isAnonymousClass()) { return error.getClass().getSuperclass().getSimpleName(); } return error.getClass().getSimpleName(); } ErrorParser(); final void error(Throwable error, SpanCustomizer customizer); final void error(Throwable error, MutableSpan span); static final ErrorParser NOOP; }
@Test public void parse_anonymous() { assertThat(ErrorParser.parse(new RuntimeException() { })).isEqualTo("RuntimeException"); }
@Test public void parse_anonymous_message() { assertThat(ErrorParser.parse(new RuntimeException("this cake is a lie") { })).isEqualTo("this cake is a lie"); }