Skip to content

Commit

Permalink
fix error reporting when external module fails to load
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Whitehead <[email protected]>
  • Loading branch information
andrewwhitehead committed Jun 30, 2019
1 parent ad97414 commit dd01ee4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
10 changes: 4 additions & 6 deletions aries_cloudagent/admin/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from marshmallow import fields, Schema

from ..classloader import ClassLoader
from ..config.base import ConfigError
from ..config.injection_context import InjectionContext
from ..messaging.outbound_message import OutboundMessage
from ..messaging.responder import BaseResponder
Expand Down Expand Up @@ -170,12 +171,9 @@ async def collect_stats(request, handler):
)
await routes_module.register(self.app)
except Exception as e:
self.logger.error(
raise ConfigError(
f"Failed to load external protocol module '{protocol_module_path}'."
+ "\n"
+ str(e)
)
raise
) from e

cors = aiohttp_cors.setup(
app,
Expand Down Expand Up @@ -288,7 +286,7 @@ async def status_reset_handler(self, request: web.BaseRequest):
collector: Collector = await self.context.inject(Collector, required=False)
if collector:
collector.reset()
raise web.HTTPOk()
return web.json_response({})

async def redirect_handler(self, request: web.BaseRequest):
"""Perform redirect to documentation."""
Expand Down
4 changes: 2 additions & 2 deletions aries_cloudagent/config/default_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ async def bind_providers(self, context: InjectionContext):
except Exception as e:
raise ConfigError(
"Failed to load external protocol module "
+ f"'{protocol_module_path}': {str(e)}."
)
+ f"'{protocol_module_path}'"
) from e
context.injector.bind_instance(ProtocolRegistry, protocol_registry)

# Register message serializer
Expand Down

0 comments on commit dd01ee4

Please sign in to comment.