44
55from pulpcore .constants import ALL_KNOWN_CONTENT_CHECKSUMS
66from pulpcore .plugin .models import Artifact
7+ from pulpcore .exceptions import DeclarativeArtifactValidationError
78
89
910class DeclarativeArtifact :
@@ -33,7 +34,7 @@ class DeclarativeArtifact:
3334 in the artifact stages. Defaults to `False`. See :ref:`on-demand-support`.
3435
3536 Raises:
36- ValueError : If `artifact`, `url`, or `relative_path` are not specified. If `remote` is not
37+ DeclarativeArtifactValidationError : If `artifact`, `url`, or `relative_path` are not specified. If `remote` is not
3738 specified and `artifact` doesn't have a file.
3839 """
3940
@@ -57,15 +58,27 @@ def __init__(
5758 deferred_download = False ,
5859 ):
5960 if not (url or urls ):
60- raise ValueError (_ ("DeclarativeArtifact must have a at least one 'url' provided" ))
61+ raise DeclarativeArtifactValidationError (
62+ _ ("DeclarativeArtifact must have a at least one 'url' provided" )
63+ )
64+
6165 if url and urls :
62- raise ValueError (_ ("DeclarativeArtifact must not provide both 'url' and 'urls'" ))
66+ raise DeclarativeArtifactValidationError (
67+ _ ("DeclarativeArtifact must not provide both 'url' and 'urls'" )
68+ )
69+
6370 if not relative_path :
64- raise ValueError (_ ("DeclarativeArtifact must have a 'relative_path'" ))
71+ raise DeclarativeArtifactValidationError (
72+ _ ("DeclarativeArtifact must have a 'relative_path'" )
73+ )
74+
6575 if not artifact :
66- raise ValueError (_ ("DeclarativeArtifact must have a 'artifact'" ))
76+ raise DeclarativeArtifactValidationError (
77+ _ ("DeclarativeArtifact must have a 'artifact'" )
78+ )
79+
6780 if not remote and not artifact .file :
68- raise ValueError (
81+ raise DeclarativeArtifactValidationError (
6982 _ (
7083 "DeclarativeArtifact must have a 'remote' if the Artifact doesn't "
7184 "have a file backing it."
0 commit comments