Skip to content

Commit 1747e6a

Browse files
committed
refactor(gax-internal): Improve error type mapping in update_from_response
1 parent b128db3 commit 1747e6a

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/gax-internal/src/observability.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -163,15 +163,13 @@ impl HttpSpanInfo {
163163
}
164164
Err(err) => {
165165
self.otel_status = OtelStatus::Error;
166-
if err.is_timeout() {
167-
self.error_type = Some("TIMEOUT".to_string());
168-
} else if err.is_connect() {
169-
self.error_type = Some("CONNECTION_ERROR".to_string());
170-
} else if err.is_request() {
171-
self.error_type = Some("REQUEST_ERROR".to_string());
172-
} else {
173-
self.error_type = Some("UNKNOWN".to_string());
174-
}
166+
let name = match err {
167+
e if e.is_timeout() => "TIMEOUT",
168+
e if e.is_connect() => "CONNECTION_ERROR",
169+
e if e.is_request() => "REQUEST_ERROR",
170+
_ => "UNKNOWN",
171+
};
172+
self.error_type = Some(name.to_string());
175173
}
176174
}
177175
}

0 commit comments

Comments
 (0)