Skip to content

Commit b91edf5

Browse files
yeesiancopybara-github
authored andcommitted
fix: raise AttributeError for accessing non-existent fields of a proto.
PiperOrigin-RevId: 614668287
1 parent f90c9cc commit b91edf5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

vertexai/generative_models/_generative_models.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1526,7 +1526,7 @@ def text(self) -> str:
15261526
if len(self.parts) > 1:
15271527
raise ValueError("Multiple content parts are not supported.")
15281528
if not self.parts:
1529-
raise ValueError("Content has no parts.")
1529+
raise AttributeError("Content has no parts.")
15301530
return self.parts[0].text
15311531

15321532

@@ -1612,7 +1612,7 @@ def to_dict(self) -> Dict[str, Any]:
16121612
@property
16131613
def text(self) -> str:
16141614
if "text" not in self._raw_part:
1615-
raise ValueError("Part has no text.")
1615+
raise AttributeError("Part has no text.")
16161616
return self._raw_part.text
16171617

16181618
@property

0 commit comments

Comments
 (0)