fix: correct exception case for invalid formatter module

This commit is contained in:
Alex Kelly 2021-11-03 17:05:45 -04:00
parent 0d92c378c4
commit 1ea47991e4

View file

@ -43,7 +43,7 @@ async def matrix_webhook(request):
format = request.rel_url.query["formatter"] format = request.rel_url.query["formatter"]
plugin = importlib.import_module(f"matrix_webhook.formatters.{format}", "formatter") plugin = importlib.import_module(f"matrix_webhook.formatters.{format}", "formatter")
data = plugin.formatter(data, request.headers) data = plugin.formatter(data, request.headers)
except AttributeError: except ModuleNotFoundError:
return utils.create_json_response( return utils.create_json_response(
HTTPStatus.BAD_REQUEST, "Unknown formatter" HTTPStatus.BAD_REQUEST, "Unknown formatter"
) )