4747from .report import run_report
4848from .resources .delete import delete_all_objects
4949from .resources .util import (
50+ abort_with_message ,
5051 app_has_semantic_search ,
5152 dry_run_import ,
5253 run_import ,
6061 update_telemetry_timestamp ,
6162)
6263from .util import (
63- abort_with_message ,
6464 check_quota_people ,
6565 close_db ,
6666 get_config ,
@@ -76,7 +76,10 @@ def run_task(task: Task, **kwargs) -> Union[AsyncResult, Any]:
7676 """Send a task to the task queue or run immediately if no queue set up."""
7777 if not current_app .config ["CELERY_CONFIG" ]:
7878 with current_app .app_context ():
79- return task (** kwargs )
79+ try :
80+ return task (** kwargs )
81+ except Exception as exc :
82+ abort_with_message (500 , str (exc ))
8083 return task .delay (** kwargs )
8184
8285
@@ -497,7 +500,7 @@ def process_transactions(
497500 ):
498501 if num_people_added or num_people_deleted :
499502 update_usage_people (tree = tree , user_id = user_id )
500- abort_with_message ( 409 , "Object has changed" )
503+ raise ValueError ( "Object has changed" )
501504 new_data = item ["new" ]
502505 if new_data :
503506 new_obj = gramps_object_from_dict (new_data )
@@ -515,11 +518,11 @@ def process_transactions(
515518 else :
516519 if num_people_added or num_people_deleted :
517520 update_usage_people (tree = tree , user_id = user_id )
518- abort_with_message ( 400 , "Unexpected transaction type" )
521+ raise ValueError ( "Unexpected transaction type" )
519522 except (KeyError , UnicodeDecodeError , json .JSONDecodeError , TypeError ):
520523 if num_people_added or num_people_deleted :
521524 update_usage_people (tree = tree , user_id = user_id )
522- abort_with_message ( 400 , "Error while processing transaction" )
525+ raise ValueError ( "Error while processing transaction" )
523526 trans_dict = transaction_to_json (trans )
524527 finally :
525528 # close the *writeable* db handle regardless of errors
@@ -570,7 +573,7 @@ def handle_commit(trans: DbTxn, class_name: str, obj) -> None:
570573def handle_add (trans : DbTxn , class_name : str , obj ) -> None :
571574 """Handle an add action."""
572575 if class_name != "Tag" and not obj .gramps_id :
573- abort_with_message ( 400 , "Gramps ID missing" )
576+ raise ValueError ( "Gramps ID missing" )
574577 handle_commit (trans , class_name , obj )
575578
576579
0 commit comments