File tree Expand file tree Collapse file tree 3 files changed +10
-7
lines changed
sdk-platform-java/gax-java/gax/src
main/java/com/google/api/gax/tracing
test/java/com/google/api/gax/tracing Expand file tree Collapse file tree 3 files changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -119,12 +119,12 @@ enum ErrorType {
119119 // Requirement source: go/clo:product-requirements-v1
120120 public static String extractErrorType (@ Nullable Throwable error ) {
121121 if (error == null ) {
122- // No information about the error; This attribute should not be recorded .
123- return null ;
122+ // No information about the error; we default to INTERNAL .
123+ return ErrorType . INTERNAL . toString () ;
124124 }
125125
126126 // 1. Unwrap standard wrapper exceptions if present
127- Throwable realError = unwrapError (error );
127+ Throwable realError = getRealCause (error );
128128
129129 // 2. Attempt to extract specific error type from the main exception
130130 String specificError = extractKnownErrorType (realError );
@@ -143,7 +143,7 @@ public static String extractErrorType(@Nullable Throwable error) {
143143 }
144144
145145 /** Unwraps standard execution wrappers to find the real cause. */
146- private static Throwable unwrapError (Throwable t ) {
146+ private static Throwable getRealCause (Throwable t ) {
147147 if (t .getCause () == null ) {
148148 return t ;
149149 }
Original file line number Diff line number Diff line change @@ -54,7 +54,8 @@ class ErrorTypeUtilTest {
5454
5555 @ Test
5656 void testExtractErrorType_null () {
57- assertThat (ErrorTypeUtil .extractErrorType (null )).isNull ();
57+ assertThat (ErrorTypeUtil .extractErrorType (null ))
58+ .isEqualTo (ErrorTypeUtil .ErrorType .INTERNAL .toString ());
5859 }
5960
6061 @ Test
Original file line number Diff line number Diff line change @@ -439,8 +439,10 @@ void testAttemptFailed_internalFallback_nullError() {
439439 // For an anonymous inner class Throwable, getSimpleName() is empty string,
440440 // which triggers the
441441 // fallback
442- verify (span , never ())
443- .setAttribute (eq (ObservabilityAttributes .ERROR_TYPE_ATTRIBUTE ), anyString ());
442+ verify (span )
443+ .setAttribute (
444+ ObservabilityAttributes .ERROR_TYPE_ATTRIBUTE ,
445+ ErrorTypeUtil .ErrorType .INTERNAL .toString ());
444446 verify (span ).end ();
445447 }
446448
You can’t perform that action at this time.
0 commit comments