2018-08-15 06:30:19 -04:00
/ *
2019-04-09 14:39:42 -04:00
* MinIO Cloud Storage , ( C ) 2019 MinIO , Inc .
2018-08-15 06:30:19 -04:00
*
* Licensed under the Apache License , Version 2.0 ( the "License" ) ;
* you may not use this file except in compliance with the License .
* You may obtain a copy of the License at
*
* http : //www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing , software
* distributed under the License is distributed on an "AS IS" BASIS ,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied .
* See the License for the specific language governing permissions and
* limitations under the License .
* /
package s3select
2019-01-08 19:53:04 -05:00
// SelectError - represents s3 select error specified in
// https://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectSELECTContent.html#RESTObjectSELECTContent-responses-special-errors.
type SelectError interface {
Cause ( ) error
ErrorCode ( ) string
ErrorMessage ( ) string
HTTPStatusCode ( ) int
Error ( ) string
}
2018-08-15 06:30:19 -04:00
2019-01-08 19:53:04 -05:00
type s3Error struct {
code string
message string
statusCode int
cause error
}
2018-08-15 06:30:19 -04:00
2019-01-08 19:53:04 -05:00
func ( err * s3Error ) Cause ( ) error {
return err . cause
}
2018-08-15 06:30:19 -04:00
2019-01-08 19:53:04 -05:00
func ( err * s3Error ) ErrorCode ( ) string {
return err . code
}
2018-08-15 06:30:19 -04:00
2019-01-08 19:53:04 -05:00
func ( err * s3Error ) ErrorMessage ( ) string {
return err . message
}
2018-08-15 06:30:19 -04:00
2019-01-08 19:53:04 -05:00
func ( err * s3Error ) HTTPStatusCode ( ) int {
return err . statusCode
}
2018-08-15 06:30:19 -04:00
2019-01-08 19:53:04 -05:00
func ( err * s3Error ) Error ( ) string {
return err . message
}
2018-08-15 06:30:19 -04:00
2019-01-08 19:53:04 -05:00
func errMalformedXML ( err error ) * s3Error {
return & s3Error {
code : "MalformedXML" ,
2019-09-10 00:33:27 -04:00
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 ( ) ,
2019-01-08 19:53:04 -05:00
statusCode : 400 ,
cause : err ,
}
}
2018-08-15 06:30:19 -04:00
2019-01-08 19:53:04 -05:00
func errInvalidCompressionFormat ( err error ) * s3Error {
return & s3Error {
code : "InvalidCompressionFormat" ,
message : "The file is not in a supported compression format. Only GZIP and BZIP2 are supported." ,
statusCode : 400 ,
cause : err ,
}
}
2018-08-15 06:30:19 -04:00
2020-03-05 22:34:04 -05:00
func errInvalidBZIP2CompressionFormat ( err error ) * s3Error {
return & s3Error {
code : "InvalidCompressionFormat" ,
message : "BZIP2 is not applicable to the queried object. Please correct the request and try again." ,
statusCode : 400 ,
cause : err ,
}
}
func errInvalidGZIPCompressionFormat ( err error ) * s3Error {
return & s3Error {
code : "InvalidCompressionFormat" ,
message : "GZIP is not applicable to the queried object. Please correct the request and try again." ,
statusCode : 400 ,
cause : err ,
}
}
2019-01-08 19:53:04 -05:00
func errInvalidDataSource ( err error ) * s3Error {
return & s3Error {
code : "InvalidDataSource" ,
message : "Invalid data source type. Only CSV, JSON, and Parquet are supported." ,
statusCode : 400 ,
cause : err ,
}
}
2018-08-15 06:30:19 -04:00
2019-01-08 19:53:04 -05:00
func errInvalidRequestParameter ( err error ) * s3Error {
return & s3Error {
code : "InvalidRequestParameter" ,
message : "The value of a parameter in SelectRequest element is invalid. Check the service API documentation and try again." ,
statusCode : 400 ,
cause : err ,
}
}
2018-08-15 06:30:19 -04:00
2019-01-08 19:53:04 -05:00
func errObjectSerializationConflict ( err error ) * s3Error {
return & s3Error {
code : "ObjectSerializationConflict" ,
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." ,
statusCode : 400 ,
cause : err ,
}
}
2018-08-15 06:30:19 -04:00
2019-01-08 19:53:04 -05:00
func errInvalidExpressionType ( err error ) * s3Error {
return & s3Error {
code : "InvalidExpressionType" ,
message : "The ExpressionType is invalid. Only SQL expressions are supported." ,
statusCode : 400 ,
cause : err ,
}
}
2018-08-15 06:30:19 -04:00
2019-01-08 19:53:04 -05:00
func errMissingRequiredParameter ( err error ) * s3Error {
return & s3Error {
code : "MissingRequiredParameter" ,
message : "The SelectRequest entity is missing a required parameter. Check the service documentation and try again." ,
statusCode : 400 ,
cause : err ,
}
}
2018-08-15 06:30:19 -04:00
2019-01-08 19:53:04 -05:00
func errTruncatedInput ( err error ) * s3Error {
return & s3Error {
code : "TruncatedInput" ,
message : "Object decompression failed. Check that the object is properly compressed using the format specified in the request." ,
statusCode : 400 ,
cause : err ,
}
2018-08-15 06:30:19 -04:00
}