Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit254e151

Browse files
committed
fix: add actionable errors for GCE long running operations
1 parent6acb3a9 commit254e151

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

‎google/api_core/exceptions.py‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,19 @@ def __init__(self, message, errors=(), details=(), response=None, error_info=Non
142142
self._error_info=error_info
143143

144144
def__str__(self):
145+
error_msg="".join([self.code,self.message])
145146
ifself.details:
146-
return"{} {} {}".format(self.code,self.message,self.details)
147+
error_msg=" ".join([error_msg,self.details])
147148
else:
148-
return"{} {}".format(self.code,self.message)
149+
ifself.errors:
150+
errors= [
151+
f"{error.code}:{error.message}"
152+
forerrorinself.errors
153+
ifhasattr(error,"code")andhasattr(error,"message")
154+
]
155+
iflen(errors)>0:
156+
error_msg="".join(error_msg,"\n".join(errors))
157+
returnerror_msg
149158

150159
@property
151160
defreason(self):

‎google/api_core/extended_operation.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,14 @@ def _handle_refreshed_operation(self):
158158
return
159159

160160
ifself.error_codeandself.error_message:
161+
errors= []
162+
ifhasattr(self,"error")andhasattr(self.error,"errors"):
163+
errors=self.error.errors
161164
exception=exceptions.from_http_status(
162165
status_code=self.error_code,
163166
message=self.error_message,
164167
response=self._extended_operation,
168+
errors=errors,
165169
)
166170
self.set_exception(exception)
167171
elifself.error_codeorself.error_message:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp