Skip to content

Commit 762f76a

Browse files
committed
Initial commit
1 parent a8f6e3d commit 762f76a

File tree

8 files changed

+346
-961
lines changed

8 files changed

+346
-961
lines changed

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
include README.md LICENSE AUTHORS.md
22
include requirements.txt requirements-dev.txt
33
include moto/py.typed
4+
include moto/cloudfront/*/*.json
45
include moto/config/resources/aws_managed_rules.json
56
include moto/ec2/*/*.json
67
include moto/ec2/resources/instance_types.json
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"version": 1.0,
3+
"merge": {
4+
"metadata": {
5+
"xmlNamespace": "http://cloudfront.amazonaws.com/doc/2020-05-31/"
6+
}
7+
}
8+
}

moto/cloudfront/exceptions.py

Lines changed: 10 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,59 @@
1-
from typing import Any
1+
from moto.core.exceptions import ServiceException
22

3-
from moto.core.exceptions import RESTError
43

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
246

257

268
class OriginDoesNotExist(CloudFrontException):
27-
code = 404
28-
299
def __init__(self) -> None:
3010
super().__init__(
3111
"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.",
3313
)
3414

3515

3616
class DomainNameNotAnS3Bucket(CloudFrontException):
3717
def __init__(self) -> None:
3818
super().__init__(
3919
"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.",
4121
)
4222

4323

4424
class DistributionAlreadyExists(CloudFrontException):
4525
def __init__(self, dist_id: str):
4626
super().__init__(
4727
"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}",
4929
)
5030

5131

5232
class InvalidIfMatchVersion(CloudFrontException):
5333
def __init__(self) -> None:
5434
super().__init__(
5535
"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.",
5737
)
5838

5939

6040
class NoSuchDistribution(CloudFrontException):
61-
code = 404
62-
6341
def __init__(self) -> None:
6442
super().__init__(
65-
"NoSuchDistribution", message="The specified distribution does not exist."
43+
"NoSuchDistribution", "The specified distribution does not exist."
6644
)
6745

6846

6947
class NoSuchOriginAccessControl(CloudFrontException):
70-
code = 404
71-
7248
def __init__(self) -> None:
7349
super().__init__(
7450
"NoSuchOriginAccessControl",
75-
message="The specified origin access control does not exist.",
51+
"The specified origin access control does not exist.",
7652
)
7753

7854

7955
class NoSuchInvalidation(CloudFrontException):
80-
code = 404
81-
8256
def __init__(self) -> None:
8357
super().__init__(
84-
"NoSuchInvalidation", message="The specified invalidation does not exist."
58+
"NoSuchInvalidation", "The specified invalidation does not exist."
8559
)

0 commit comments

Comments
 (0)