storj.io/minio@v0.0.0-20230509071714-0cbc90f649b1/pkg/s3select/errors.go (about) 1 /* 2 * MinIO Cloud Storage, (C) 2019 MinIO, Inc. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package s3select 18 19 // SelectError - represents s3 select error specified in 20 // https://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectSELECTContent.html#RESTObjectSELECTContent-responses-special-errors. 21 type SelectError interface { 22 Cause() error 23 ErrorCode() string 24 ErrorMessage() string 25 HTTPStatusCode() int 26 Error() string 27 } 28 29 type s3Error struct { 30 code string 31 message string 32 statusCode int 33 cause error 34 } 35 36 func (err *s3Error) Cause() error { 37 return err.cause 38 } 39 40 func (err *s3Error) ErrorCode() string { 41 return err.code 42 } 43 44 func (err *s3Error) ErrorMessage() string { 45 return err.message 46 } 47 48 func (err *s3Error) HTTPStatusCode() int { 49 return err.statusCode 50 } 51 52 func (err *s3Error) Error() string { 53 return err.message 54 } 55 56 func errMalformedXML(err error) *s3Error { 57 return &s3Error{ 58 code: "MalformedXML", 59 message: "The XML provided was not well-formed or did not validate against our published schema. Check the service documentation and try again: " + err.Error(), 60 statusCode: 400, 61 cause: err, 62 } 63 } 64 65 func errInvalidCompressionFormat(err error) *s3Error { 66 return &s3Error{ 67 code: "InvalidCompressionFormat", 68 message: "The file is not in a supported compression format. Only GZIP and BZIP2 are supported.", 69 statusCode: 400, 70 cause: err, 71 } 72 } 73 74 func errInvalidBZIP2CompressionFormat(err error) *s3Error { 75 return &s3Error{ 76 code: "InvalidCompressionFormat", 77 message: "BZIP2 is not applicable to the queried object. Please correct the request and try again.", 78 statusCode: 400, 79 cause: err, 80 } 81 } 82 83 func errInvalidGZIPCompressionFormat(err error) *s3Error { 84 return &s3Error{ 85 code: "InvalidCompressionFormat", 86 message: "GZIP is not applicable to the queried object. Please correct the request and try again.", 87 statusCode: 400, 88 cause: err, 89 } 90 } 91 92 func errInvalidDataSource(err error) *s3Error { 93 return &s3Error{ 94 code: "InvalidDataSource", 95 message: "Invalid data source type. Only CSV, JSON, and Parquet are supported.", 96 statusCode: 400, 97 cause: err, 98 } 99 } 100 101 func errInvalidRequestParameter(err error) *s3Error { 102 return &s3Error{ 103 code: "InvalidRequestParameter", 104 message: "The value of a parameter in SelectRequest element is invalid. Check the service API documentation and try again.", 105 statusCode: 400, 106 cause: err, 107 } 108 } 109 110 func errObjectSerializationConflict(err error) *s3Error { 111 return &s3Error{ 112 code: "ObjectSerializationConflict", 113 message: "InputSerialization specifies more than one format (CSV, JSON, or Parquet), or OutputSerialization specifies more than one format (CSV or JSON). InputSerialization and OutputSerialization can only specify one format each.", 114 statusCode: 400, 115 cause: err, 116 } 117 } 118 119 func errInvalidExpressionType(err error) *s3Error { 120 return &s3Error{ 121 code: "InvalidExpressionType", 122 message: "The ExpressionType is invalid. Only SQL expressions are supported.", 123 statusCode: 400, 124 cause: err, 125 } 126 } 127 128 func errMissingRequiredParameter(err error) *s3Error { 129 return &s3Error{ 130 code: "MissingRequiredParameter", 131 message: "The SelectRequest entity is missing a required parameter. Check the service documentation and try again.", 132 statusCode: 400, 133 cause: err, 134 } 135 } 136 137 func errTruncatedInput(err error) *s3Error { 138 return &s3Error{ 139 code: "TruncatedInput", 140 message: "Object decompression failed. Check that the object is properly compressed using the format specified in the request.", 141 statusCode: 400, 142 cause: err, 143 } 144 }