|
34 | 34 | import com.google.api.core.InternalApi; |
35 | 35 | import com.google.api.gax.logging.LoggerProvider; |
36 | 36 | import com.google.api.gax.logging.LoggingUtils; |
37 | | -import com.google.api.gax.rpc.ApiException; |
38 | 37 | import com.google.rpc.ErrorInfo; |
39 | 38 | import java.util.HashMap; |
40 | 39 | import java.util.Map; |
@@ -104,17 +103,12 @@ private void recordActionableError(Throwable error) { |
104 | 103 | ObservabilityUtils.extractStatus(error)); |
105 | 104 | } |
106 | 105 |
|
107 | | - if (error instanceof ApiException) { |
108 | | - ApiException apiException = (ApiException) error; |
109 | | - if (apiException.getErrorDetails() != null) { |
110 | | - ErrorInfo errorInfo = apiException.getErrorDetails().getErrorInfo(); |
111 | | - if (errorInfo != null) { |
112 | | - logContext.put("error.type", errorInfo.getReason()); |
113 | | - logContext.put("gcp.errors.domain", errorInfo.getDomain()); |
114 | | - for (Map.Entry<String, String> entry : errorInfo.getMetadataMap().entrySet()) { |
115 | | - logContext.put("gcp.errors.metadata." + entry.getKey(), entry.getValue()); |
116 | | - } |
117 | | - } |
| 106 | + ErrorInfo errorInfo = ObservabilityUtils.extractErrorInfo(error); |
| 107 | + if (errorInfo != null) { |
| 108 | + logContext.put("error.type", errorInfo.getReason()); |
| 109 | + logContext.put("gcp.errors.domain", errorInfo.getDomain()); |
| 110 | + for (Map.Entry<String, String> entry : errorInfo.getMetadataMap().entrySet()) { |
| 111 | + logContext.put("gcp.errors.metadata." + entry.getKey(), entry.getValue()); |
118 | 112 | } |
119 | 113 | } |
120 | 114 |
|
|
0 commit comments