@@ -32,10 +32,18 @@ import (
32
32
func (c * Client ) GetObject (ctx context.Context , bucketName , objectName string , opts GetObjectOptions ) (* Object , error ) {
33
33
// Input validation.
34
34
if err := s3utils .CheckValidBucketName (bucketName ); err != nil {
35
- return nil , err
35
+ return nil , ErrorResponse {
36
+ StatusCode : http .StatusBadRequest ,
37
+ Code : "InvalidBucketName" ,
38
+ Message : err .Error (),
39
+ }
36
40
}
37
41
if err := s3utils .CheckValidObjectName (objectName ); err != nil {
38
- return nil , err
42
+ return nil , ErrorResponse {
43
+ StatusCode : http .StatusBadRequest ,
44
+ Code : "XMinioInvalidObjectName" ,
45
+ Message : err .Error (),
46
+ }
39
47
}
40
48
41
49
gctx , cancel := context .WithCancel (ctx )
@@ -649,10 +657,18 @@ func newObject(ctx context.Context, cancel context.CancelFunc, reqCh chan<- getR
649
657
func (c * Client ) getObject (ctx context.Context , bucketName , objectName string , opts GetObjectOptions ) (io.ReadCloser , ObjectInfo , http.Header , error ) {
650
658
// Validate input arguments.
651
659
if err := s3utils .CheckValidBucketName (bucketName ); err != nil {
652
- return nil , ObjectInfo {}, nil , err
660
+ return nil , ObjectInfo {}, nil , ErrorResponse {
661
+ StatusCode : http .StatusBadRequest ,
662
+ Code : "InvalidBucketName" ,
663
+ Message : err .Error (),
664
+ }
653
665
}
654
666
if err := s3utils .CheckValidObjectName (objectName ); err != nil {
655
- return nil , ObjectInfo {}, nil , err
667
+ return nil , ObjectInfo {}, nil , ErrorResponse {
668
+ StatusCode : http .StatusBadRequest ,
669
+ Code : "XMinioInvalidObjectName" ,
670
+ Message : err .Error (),
671
+ }
656
672
}
657
673
658
674
// Execute GET on objectName.
0 commit comments