mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-23 15:57:23 -04:00
Refactored register_errorhandlers so that it handles HTTPError
Remove most cases where we catch HTTPError
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
from flask import url_for, abort, current_app
|
||||
from flask import url_for, current_app
|
||||
from app import notifications_api_client
|
||||
from app.utils import BrowsableItem
|
||||
from notifications_python_client.errors import HTTPError
|
||||
|
||||
|
||||
def insert_new_service(service_name, user_id):
|
||||
@@ -26,15 +25,7 @@ def get_service_by_id(id_):
|
||||
|
||||
|
||||
def get_service_by_id_or_404(id_):
|
||||
try:
|
||||
return notifications_api_client.get_service(id_)['data']
|
||||
except KeyError:
|
||||
abort(404)
|
||||
except HTTPError as e:
|
||||
if e.status_code == 404:
|
||||
abort(404)
|
||||
else:
|
||||
raise e
|
||||
return notifications_api_client.get_service(id_)['data']
|
||||
|
||||
|
||||
def get_services(user_id=None):
|
||||
|
||||
@@ -22,10 +22,7 @@ def get_service_template_or_404(service_id, template_id):
|
||||
try:
|
||||
return notifications_api_client.get_service_template(service_id, template_id)
|
||||
except HTTPError as e:
|
||||
if e.status_code == 404:
|
||||
abort(404)
|
||||
else:
|
||||
raise e
|
||||
abort(e.status_code)
|
||||
|
||||
|
||||
def delete_service_template(service_id, template_id):
|
||||
|
||||
Reference in New Issue
Block a user