Skip to content

Commit b8484d2

Browse files
committed
Add try execpt error handling to webhook handler. This simple fix
should print the error class without the stacktrace and without breaking the entire controller. * Do we want the entire stacktrace or more info instead?
1 parent b74af56 commit b8484d2

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

libs/aries-basic-controller/aries_basic_controller/aries_controller.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
ClientRequest,
55
)
66
from pubsub import pub
7+
import sys
78

89
from .controllers.connections import ConnectionsController
910
from .controllers.messaging import MessagingController
@@ -169,12 +170,15 @@ def remove_all_listeners(self, topic: str = None):
169170
pub.unsubAll(topicName=topic)
170171

171172
async def listen_webhooks(self):
172-
app = web.Application()
173-
app.add_routes([web.post(self.webhook_base + "/topic/{topic}/", self._receive_webhook)])
174-
runner = web.AppRunner(app)
175-
await runner.setup()
176-
self.webhook_site = web.TCPSite(runner, self.webhook_host, self.webhook_port)
177-
await self.webhook_site.start()
173+
try:
174+
app = web.Application()
175+
app.add_routes([web.post(self.webhook_base + "/topic/{topic}/", self._receive_webhook)])
176+
runner = web.AppRunner(app)
177+
await runner.setup()
178+
self.webhook_site = web.TCPSite(runner, self.webhook_host, self.webhook_port)
179+
await self.webhook_site.start()
180+
except:
181+
print("Listening webhooks failed!", sys.exc_info()[0], "occurred.")
178182

179183
async def _receive_webhook(self, request: ClientRequest):
180184
topic = request.match_info["topic"]

0 commit comments

Comments
 (0)