github.com/minio/minio@v0.0.0-20240328213742-3f72439b8a27/internal/s3select/json/errors.go (about) 1 // Copyright (c) 2015-2021 MinIO, Inc. 2 // 3 // This file is part of MinIO Object Storage stack 4 // 5 // This program is free software: you can redistribute it and/or modify 6 // it under the terms of the GNU Affero General Public License as published by 7 // the Free Software Foundation, either version 3 of the License, or 8 // (at your option) any later version. 9 // 10 // This program is distributed in the hope that it will be useful 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU Affero General Public License for more details. 14 // 15 // You should have received a copy of the GNU Affero General Public License 16 // along with this program. If not, see <http://www.gnu.org/licenses/>. 17 18 package json 19 20 type s3Error struct { 21 code string 22 message string 23 statusCode int 24 cause error 25 } 26 27 func (err *s3Error) Cause() error { 28 return err.cause 29 } 30 31 func (err *s3Error) ErrorCode() string { 32 return err.code 33 } 34 35 func (err *s3Error) ErrorMessage() string { 36 return err.message 37 } 38 39 func (err *s3Error) HTTPStatusCode() int { 40 return err.statusCode 41 } 42 43 func (err *s3Error) Error() string { 44 return err.message 45 } 46 47 func errInvalidJSONType(err error) *s3Error { 48 return &s3Error{ 49 code: "InvalidJsonType", 50 message: "The JsonType is invalid. Only DOCUMENT and LINES are supported.", 51 statusCode: 400, 52 cause: err, 53 } 54 } 55 56 func errJSONParsingError(err error) *s3Error { 57 return &s3Error{ 58 code: "JSONParsingError", 59 message: "Encountered an error parsing the JSON file. Check the file and try again.", 60 statusCode: 400, 61 cause: err, 62 } 63 }