added public method 'create_with_unified_error' used in publisher

This commit is contained in:
Jakub Trllo 2023-02-09 12:58:51 +01:00
parent b148dec048
commit fac10d2633
2 changed files with 27 additions and 1 deletions

View file

@ -1576,6 +1576,31 @@ class CreateContext:
identifier, label, exc_info, add_traceback
)
return result, fail_info
def create_with_unified_error(self, identifier, *args, **kwargs):
"""Trigger create but raise only one error if anything fails.
Added to raise unified exception. Capture any possible issues and
reraise it with unified information.
Args:
identifier (str): Identifier of creator.
*args (Tuple[Any]): Arguments for create method.
**kwargs (Dict[Any, Any]): Keyword argument for create method.
Raises:
CreatorsCreateFailed: When creation fails due to any possible
reason. If anything goes wrong this is only possible exception
the method should raise.
"""
result, fail_info = self._create_with_unified_error(
identifier, None, *args, **kwargs
)
if fail_info is not None:
raise CreatorsCreateFailed([fail_info])
return result
def creator_removed_instance(self, instance):
"""When creator removes instance context should be acknowledged.

View file

@ -2017,9 +2017,10 @@ class PublisherController(BasePublisherController):
success = True
try:
self._create_context.raw_create(
self._create_context.create_with_unified_error(
creator_identifier, subset_name, instance_data, options
)
except CreatorsOperationFailed as exc:
success = False
self._emit_event(