Browse code

Fix inspect object by invalid reference

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>

Tonis Tiigi authored on 2016/12/24 15:57:30
Showing 2 changed files
... ...
@@ -456,3 +456,11 @@ func (s *DockerSuite) TestInspectUnknownObject(c *check.C) {
456 456
 	c.Assert(out, checker.Contains, "Error: No such object: foobar")
457 457
 	c.Assert(err.Error(), checker.Contains, "Error: No such object: foobar")
458 458
 }
459
+
460
+func (s *DockerSuite) TestInpectInvalidReference(c *check.C) {
461
+	// This test should work on both Windows and Linux
462
+	out, _, err := dockerCmdWithError("inspect", "FooBar")
463
+	c.Assert(err, checker.NotNil)
464
+	c.Assert(out, checker.Contains, "Error: No such object: FooBar")
465
+	c.Assert(err.Error(), checker.Contains, "Error: No such object: FooBar")
466
+}
... ...
@@ -232,7 +232,7 @@ func (ps *Store) resolvePluginID(idOrName string) (string, error) {
232 232
 
233 233
 	ref, err := reference.ParseNamed(idOrName)
234 234
 	if err != nil {
235
-		return "", errors.Wrapf(err, "failed to parse %v", idOrName)
235
+		return "", errors.WithStack(ErrNotFound(idOrName))
236 236
 	}
237 237
 	if _, ok := ref.(reference.Canonical); ok {
238 238
 		logrus.Warnf("canonical references cannot be resolved: %v", ref.String())