|
1 | | -from typing import Any |
| 1 | +from moto.core.exceptions import ServiceException |
2 | 2 |
|
3 | | -from moto.core.exceptions import RESTError |
4 | 3 |
|
5 | | -EXCEPTION_RESPONSE = """<?xml version="1.0"?> |
6 | | -<ErrorResponse xmlns="http://cloudfront.amazonaws.com/doc/2020-05-31/"> |
7 | | - <Error> |
8 | | - <Type>Sender</Type> |
9 | | - <Code>{{ error_type }}</Code> |
10 | | - <Message>{{ message }}</Message> |
11 | | - </Error> |
12 | | - <{{ request_id_tag }}>30c0dedb-92b1-4e2b-9be4-1188e3ed86ab</{{ request_id_tag }}> |
13 | | -</ErrorResponse>""" |
14 | | - |
15 | | - |
16 | | -class CloudFrontException(RESTError): |
17 | | - code = 400 |
18 | | - extended_templates = {"cferror": EXCEPTION_RESPONSE} |
19 | | - env = RESTError.extended_environment(extended_templates) |
20 | | - |
21 | | - def __init__(self, error_type: str, message: str, **kwargs: Any): |
22 | | - kwargs.setdefault("template", "cferror") |
23 | | - super().__init__(error_type, message, **kwargs) |
| 4 | +class CloudFrontException(ServiceException): |
| 5 | + pass |
24 | 6 |
|
25 | 7 |
|
26 | 8 | class OriginDoesNotExist(CloudFrontException): |
27 | | - code = 404 |
28 | | - |
29 | 9 | def __init__(self) -> None: |
30 | 10 | super().__init__( |
31 | 11 | "NoSuchOrigin", |
32 | | - message="One or more of your origins or origin groups do not exist.", |
| 12 | + "One or more of your origins or origin groups do not exist.", |
33 | 13 | ) |
34 | 14 |
|
35 | 15 |
|
36 | 16 | class DomainNameNotAnS3Bucket(CloudFrontException): |
37 | 17 | def __init__(self) -> None: |
38 | 18 | super().__init__( |
39 | 19 | "InvalidArgument", |
40 | | - message="The parameter Origin DomainName does not refer to a valid S3 bucket.", |
| 20 | + "The parameter Origin DomainName does not refer to a valid S3 bucket.", |
41 | 21 | ) |
42 | 22 |
|
43 | 23 |
|
44 | 24 | class DistributionAlreadyExists(CloudFrontException): |
45 | 25 | def __init__(self, dist_id: str): |
46 | 26 | super().__init__( |
47 | 27 | "DistributionAlreadyExists", |
48 | | - message=f"The caller reference that you are using to create a distribution is associated with another distribution. Already exists: {dist_id}", |
| 28 | + f"The caller reference that you are using to create a distribution is associated with another distribution. Already exists: {dist_id}", |
49 | 29 | ) |
50 | 30 |
|
51 | 31 |
|
52 | 32 | class InvalidIfMatchVersion(CloudFrontException): |
53 | 33 | def __init__(self) -> None: |
54 | 34 | super().__init__( |
55 | 35 | "InvalidIfMatchVersion", |
56 | | - message="The If-Match version is missing or not valid for the resource.", |
| 36 | + "The If-Match version is missing or not valid for the resource.", |
57 | 37 | ) |
58 | 38 |
|
59 | 39 |
|
60 | 40 | class NoSuchDistribution(CloudFrontException): |
61 | | - code = 404 |
62 | | - |
63 | 41 | def __init__(self) -> None: |
64 | 42 | super().__init__( |
65 | | - "NoSuchDistribution", message="The specified distribution does not exist." |
| 43 | + "NoSuchDistribution", "The specified distribution does not exist." |
66 | 44 | ) |
67 | 45 |
|
68 | 46 |
|
69 | 47 | class NoSuchOriginAccessControl(CloudFrontException): |
70 | | - code = 404 |
71 | | - |
72 | 48 | def __init__(self) -> None: |
73 | 49 | super().__init__( |
74 | 50 | "NoSuchOriginAccessControl", |
75 | | - message="The specified origin access control does not exist.", |
| 51 | + "The specified origin access control does not exist.", |
76 | 52 | ) |
77 | 53 |
|
78 | 54 |
|
79 | 55 | class NoSuchInvalidation(CloudFrontException): |
80 | | - code = 404 |
81 | | - |
82 | 56 | def __init__(self) -> None: |
83 | 57 | super().__init__( |
84 | | - "NoSuchInvalidation", message="The specified invalidation does not exist." |
| 58 | + "NoSuchInvalidation", "The specified invalidation does not exist." |
85 | 59 | ) |
0 commit comments