From 9caa205f40d2d6a6dc045447273248d111416b28 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Tue, 17 Nov 2015 14:49:16 -0800 Subject: [PATCH] pipe: Print a helpful message for s3 upon invalid arguments. Fixes #1373 --- pkg/client/errors.go | 11 +++++++++-- pkg/client/s3/s3.go | 3 +++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/pkg/client/errors.go b/pkg/client/errors.go index 083c2855..c07f4f0c 100644 --- a/pkg/client/errors.go +++ b/pkg/client/errors.go @@ -125,16 +125,23 @@ func (e BrokenSymlink) Error() string { return "Requested file ‘" + e.Path + "’ has broken symlink" } -// TooManyLevelsSymlink (ELOOP) - file has too many levels of symlinks +// TooManyLevelsSymlink (ELOOP) - file has too many levels of symlinks. type TooManyLevelsSymlink GenericFileError func (e TooManyLevelsSymlink) Error() string { return "Requested file ‘" + e.Path + "’ has too many levels of symlinks" } -// EmptyPath (EINVAL) - invalid argument +// EmptyPath (EINVAL) - invalid argument. type EmptyPath struct{} func (e EmptyPath) Error() string { return "Invalid path, path cannot be empty" } + +// ObjectMissing (EINVAL) - object key missing. +type ObjectMissing struct{} + +func (e ObjectMissing) Error() string { + return "Object key is missing, object key cannot be empty" +} diff --git a/pkg/client/s3/s3.go b/pkg/client/s3/s3.go index 5ee53fdf..e5877f41 100644 --- a/pkg/client/s3/s3.go +++ b/pkg/client/s3/s3.go @@ -157,6 +157,9 @@ func (c *s3Client) Put(size int64, data io.Reader) *probe.Error { if errResponse.Code == "MethodNotAllowed" { return probe.NewError(client.ObjectAlreadyExists{Object: object}) } + if errResponse.Code == "InvalidArgument" { + return probe.NewError(client.ObjectMissing{}) + } } return probe.NewError(err) }