1+ using System ;
2+
3+ #pragma warning disable SA1402
4+ namespace Microsoft . ComponentDetection . Common
5+ {
6+ public class DockerReferenceException : Exception
7+ {
8+ public DockerReferenceException ( string reference , string exceptionErrorMessage )
9+ : base ( $ "Error while parsing docker reference { reference } : { exceptionErrorMessage } ")
10+ {
11+ }
12+ }
13+
14+ // ReferenceInvalidFormat represents an error while trying to parse a string as a reference.
15+ public class ReferenceInvalidFormatException : DockerReferenceException
16+ {
17+ private const string ErrorMessage = "invalid reference format" ;
18+
19+ public ReferenceInvalidFormatException ( string reference )
20+ : base ( reference , ErrorMessage )
21+ {
22+ }
23+ }
24+
25+ // TagInvalidFormat represents an error while trying to parse a string as a tag.
26+ public class ReferenceTagInvalidFormatException : DockerReferenceException
27+ {
28+ private const string ErrorMessage = "invalid tag format" ;
29+
30+ public ReferenceTagInvalidFormatException ( string reference )
31+ : base ( reference , ErrorMessage )
32+ {
33+ }
34+ }
35+
36+ // DigestInvalidFormat represents an error while trying to parse a string as a tag.
37+ public class ReferenceDigestInvalidFormatException : DockerReferenceException
38+ {
39+ private const string ErrorMessage = "invalid digest format" ;
40+
41+ public ReferenceDigestInvalidFormatException ( string reference )
42+ : base ( reference , ErrorMessage )
43+ {
44+ }
45+ }
46+
47+ // NameContainsUppercase is returned for invalid repository names that contain uppercase characters.
48+ public class ReferenceNameContainsUppercaseException : DockerReferenceException
49+ {
50+ private const string ErrorMessage = "repository name must be lowercase" ;
51+
52+ public ReferenceNameContainsUppercaseException ( string reference )
53+ : base ( reference , ErrorMessage )
54+ {
55+ }
56+ }
57+
58+ // NameEmpty is returned for empty, invalid repository names.
59+ public class ReferenceNameEmptyException : DockerReferenceException
60+ {
61+ private const string ErrorMessage = "repository name must have at least one component" ;
62+
63+ public ReferenceNameEmptyException ( string reference )
64+ : base ( reference , ErrorMessage )
65+ {
66+ }
67+ }
68+
69+ // ErrNameTooLong is returned when a repository name is longer than NameTotalLengthMax.
70+ public class ReferenceNameTooLongException : DockerReferenceException
71+ {
72+ private const string ErrorMessage = "repository name must not be more than 255 characters" ;
73+
74+ public ReferenceNameTooLongException ( string reference )
75+ : base ( reference , ErrorMessage )
76+ {
77+ }
78+ }
79+
80+ // ErrNameNotCanonical is returned when a name is not canonical.
81+ public class ReferenceNameNotCanonicalException : DockerReferenceException
82+ {
83+ private const string ErrorMessage = "repository name must be canonical" ;
84+
85+ public ReferenceNameNotCanonicalException ( string reference )
86+ : base ( reference , ErrorMessage )
87+ {
88+ }
89+ }
90+
91+ public class InvalidDigestFormatError : DockerReferenceException
92+ {
93+ private const string ErrorMessage = "invalid digest format" ;
94+
95+ public InvalidDigestFormatError ( string reference )
96+ : base ( reference , ErrorMessage )
97+ {
98+ }
99+ }
100+
101+ public class UnsupportedAlgorithmError : DockerReferenceException
102+ {
103+ private const string ErrorMessage = "unsupported digest algorithm" ;
104+
105+ public UnsupportedAlgorithmError ( string reference )
106+ : base ( reference , ErrorMessage )
107+ {
108+ }
109+ }
110+
111+ public class InvalidDigestLengthError : DockerReferenceException
112+ {
113+ private const string ErrorMessage = "invalid checksum digest length" ;
114+
115+ public InvalidDigestLengthError ( string reference )
116+ : base ( reference , ErrorMessage )
117+ {
118+ }
119+ }
120+ }
0 commit comments