Skip to content

Commit eb2c624

Browse files
authored
Refactor Gemini API call error handling
1 parent 2b1747b commit eb2c624

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

modules/python/src/custom_nodes/google_genmedia/gemini_nodes.py

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -413,21 +413,14 @@ def generate_content(
413413
) from e
414414

415415
# Make the API call
416-
try:
417-
print(
418-
f"Making Gemini API call with the following Model : {GeminiModel[model]} , config {gen_config_obj}"
419-
)
420-
response = self.client.models.generate_content(
421-
model=GeminiModel[model],
422-
contents=contents,
423-
config=gen_config_obj,
424-
)
425-
except APIExecutionError as e:
426-
raise RuntimeError(f"Gemini API Error: {e}") from e
427-
except Exception as e:
428-
raise RuntimeError(
429-
f"An unexpected error occurred during Gemini API call: {e}"
430-
) from e
416+
print(
417+
f"Making Gemini API call with the following Model : {GeminiModel[model]} , config {gen_config_obj}"
418+
)
419+
response = self.client.models.generate_content(
420+
model=GeminiModel[model],
421+
contents=contents,
422+
config=gen_config_obj,
423+
)
431424

432425
# Process the response
433426
try:

0 commit comments

Comments
 (0)