googleapis / python-pubsub

Apache License 2.0
392 stars 205 forks source link

Stack trace logged after calling code has already handled the exception. #1086

Closed mukund-ananthu closed 9 months ago

mukund-ananthu commented 9 months ago

Steps to reproduce

Run the code example provided on a valid topic and project.

Code example

from google.cloud import pubsub_v1
from google.api_core.exceptions import InvalidArgument

publisher = pubsub_v1.PublisherClient()
topic_path = publisher.topic_path(
    "project-id", "topic-name"
)
payload = b"test-message"

try:
  future = publisher.publish(
      topic=topic_path,
      data=payload,
  )

  print(future.result())
except InvalidArgument:
  print("Caught error: Message failed schema validation")

Stack trace

Caught error: Message failed schema validation
Failed to publish 1 messages.
Traceback (most recent call last):
... rest of traceback