From 019751daa8df3c62eb4fa971dbe7ee671c133a1f Mon Sep 17 00:00:00 2001 From: Joffrey F Date: Mon, 27 Apr 2015 11:26:45 -0700 Subject: Use custom Error class (inherits DockerException and ValueError) --- docker/errors.py | 4 ++++ docker/utils/decorators.py | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) 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 -- cgit v1.2.1