diff options
author | Joffrey F <joffrey@docker.com> | 2015-04-27 11:26:45 -0700 |
---|---|---|
committer | Joffrey F <joffrey@docker.com> | 2015-04-27 11:26:45 -0700 |
commit | 019751daa8df3c62eb4fa971dbe7ee671c133a1f (patch) | |
tree | cbc88f5cc0ca2a06882a39d375c0e1e5575fd9f1 | |
parent | c2d48652ce9e5808bfa3f22b2daec34e88d5e9df (diff) | |
download | docker-py-check_resource_not_none.tar.gz |
Use custom Error class (inherits DockerException and ValueError)check_resource_not_none
-rw-r--r-- | docker/errors.py | 4 | ||||
-rw-r--r-- | docker/utils/decorators.py | 5 |
2 files changed, 8 insertions, 1 deletions
diff --git a/docker/errors.py b/docker/errors.py index fb9cb5a..d15e332 100644 --- a/docker/errors.py +++ b/docker/errors.py @@ -78,3 +78,7 @@ class TLSParameterError(DockerException): "client configurations. See " "http://docs.docker.com/examples/https/ for " "API details.") + + +class NullResource(DockerException, ValueError): + pass diff --git a/docker/utils/decorators.py b/docker/utils/decorators.py index 897db32..8d07f93 100644 --- a/docker/utils/decorators.py +++ b/docker/utils/decorators.py @@ -1,3 +1,4 @@ +import docker.errors def check_resource(f): @@ -5,6 +6,8 @@ def check_resource(f): if resource_id is None and ( kwargs.get('container') is None and kwargs.get('image') is None ): - raise ValueError('image or container param is None') + raise docker.errors.NullResource( + 'image or container param is None' + ) return f(self, resource_id, *args, **kwargs) return wrapped |