Skip to content
This repository was archived by the owner on Feb 23, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: changes "error_details" to "details".
  • Loading branch information
Aza Tulepbergenov
Aza Tulepbergenov committed Oct 18, 2021
commit 02b082a667fe0b73907b670ebbfac606a11d74e7
6 changes: 3 additions & 3 deletions google/api_core/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ def __init__(self, message, errors=(), details=(), response=None):
self._response = response

def __str__(self):
if self.error_details:
return "{} {} {}".format(self.code, self.message, self.error_details)
if self.details:
return "{} {} {}".format(self.code, self.message, self.details)
else:
return "{} {}".format(self.code, self.message)

Expand All @@ -146,7 +146,7 @@ def errors(self):
return list(self._errors)

@property
def error_details(self):
def details(self):
"""Information contained in google.rpc.status.details.

Reference:
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/test_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def test_error_details_from_rest_response():
)
exception = exceptions.from_http_response(http_response)
want_error_details = [json.loads(json_format.MessageToJson(bad_request_detail))]
assert want_error_details == exception.error_details
assert want_error_details == exception.details
# 404 POST comes from make_response.
assert str(exception) == (
"404 POST https://example.com/: 3 INVALID_ARGUMENT:"
Expand All @@ -271,7 +271,7 @@ def test_error_details_from_v1_rest_response():
).encode("utf-8")
)
exception = exceptions.from_http_response(response)
assert exception.error_details == []
assert exception.details == []


def test_error_details_from_grpc_response():
Comment thread
atulep marked this conversation as resolved.
Expand All @@ -292,7 +292,7 @@ def test_error_details_from_grpc_response():

bad_request_detail = error_details_pb2.BadRequest()
status_detail.Unpack(bad_request_detail)
assert exception.error_details == [bad_request_detail]
assert exception.details == [bad_request_detail]


def test_error_details_from_grpc_response_unknown_error():
Comment thread
atulep marked this conversation as resolved.
Expand All @@ -309,4 +309,4 @@ def test_error_details_from_grpc_response_unknown_error():
with mock.patch("grpc_status.rpc_status.from_call") as m:
m.return_value = status
exception = exceptions.from_grpc_error(error)
assert exception.error_details == [status_detail]
assert exception.details == [status_detail]