Add more error handling to the ECR backend

The error messages were copied from `botocore`.
New exceptions: RepositoryNotFoundException & ImageNotFoundException.
This commit is contained in:
Hugo Lopes Tavares 2017-08-10 19:33:38 -04:00
commit e4da4f6cd5
5 changed files with 112 additions and 33 deletions

22
moto/ecr/exceptions.py Normal file
View file

@ -0,0 +1,22 @@
from __future__ import unicode_literals
from moto.core.exceptions import RESTError
class RepositoryNotFoundException(RESTError):
code = 400
def __init__(self, repository_name, registry_id):
super(RepositoryNotFoundException, self).__init__(
error_type="RepositoryNotFoundException",
message="The repository with name '{0}' does not exist in the registry "
"with id '{1}'".format(repository_name, registry_id))
class ImageNotFoundException(RESTError):
code = 400
def __init__(self, image_id, repository_name, registry_id):
super(ImageNotFoundException, self).__init__(
error_type="ImageNotFoundException",
message="The image with imageId {0} does not exist within the repository with name '{1}' "
"in the registry with id '{2}'".format(image_id, repository_name, registry_id))