mirror of
https://github.com/ansible/awx.git
synced 2026-01-16 20:30:46 -03:30
use more precise exception
This commit is contained in:
parent
f47f8abe42
commit
a5b1c7b579
@ -609,7 +609,7 @@ class UnifiedJobSerializer(BaseSerializer):
|
||||
summary_fields['source_workflow_job'] = {}
|
||||
try:
|
||||
summary_obj = obj.unified_job_node.workflow_job
|
||||
except ObjectDoesNotExist:
|
||||
except UnifiedJob.unified_job_node.RelatedObjectDoesNotExist:
|
||||
return summary_fields
|
||||
|
||||
for field in SUMMARIZABLE_FK_FIELDS['job']:
|
||||
|
||||
@ -20,7 +20,6 @@ from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.timezone import now
|
||||
from django.utils.encoding import smart_text
|
||||
from django.apps import apps
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
|
||||
# Django-Polymorphic
|
||||
from polymorphic import PolymorphicModel
|
||||
@ -783,7 +782,7 @@ class UnifiedJob(PolymorphicModel, PasswordFieldsModel, CommonModelNameNotUnique
|
||||
if self.spawned_by_workflow:
|
||||
try:
|
||||
return self.unified_job_node.workflow_job.pk
|
||||
except ObjectDoesNotExist:
|
||||
except UnifiedJob.unified_job_node.RelatedObjectDoesNotExist:
|
||||
pass
|
||||
return None
|
||||
|
||||
@ -792,7 +791,7 @@ class UnifiedJob(PolymorphicModel, PasswordFieldsModel, CommonModelNameNotUnique
|
||||
if self.spawned_by_workflow:
|
||||
try:
|
||||
return self.unified_job_node.pk
|
||||
except ObjectDoesNotExist:
|
||||
except UnifiedJob.unified_job_node.RelatedObjectDoesNotExist:
|
||||
pass
|
||||
return None
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user