OmniSciDB  085a039ca4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ForeignStorageException.h
Go to the documentation of this file.
1 /*
2  * Copyright 2020 OmniSci, 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 #pragma once
17 
18 #include <stdexcept>
19 #include <string>
20 
21 namespace foreign_storage {
22 
23 class ForeignStorageException : public std::runtime_error {
24  public:
25  ForeignStorageException(const std::string& error_message)
26  : std::runtime_error(error_message) {}
27 };
28 
29 class MetadataScanInfeasibleFragmentSizeException : public std::runtime_error {
30  public:
31  MetadataScanInfeasibleFragmentSizeException(const std::string& error_message)
32  : std::runtime_error(error_message), min_feasible_fragment_size_(-1) {}
33 
34  int32_t
35  min_feasible_fragment_size_; // may be set to indicate what the minimum feasible
36  // fragment size for metadata scan should be
37 };
38 
39 inline void throw_removed_row_in_result_set_error(const std::string& select_statement) {
41  "Refresh of foreign table created with \"APPEND\" update type failed as result set "
42  "of select statement "
43  "reduced in size: \"" +
44  select_statement + "\""};
45 }
46 
47 inline void throw_removed_row_in_file_error(const std::string& file_path) {
49  "Refresh of foreign table created with \"APPEND\" update type failed as file "
50  "reduced in size: \"" +
51  file_path + "\""};
52 }
53 
54 inline void throw_removed_file_error(const std::string& file_path) {
56  "Refresh of foreign table created with \"APPEND\" update type failed as "
57  "file \"" +
58  file_path + "\" was removed."};
59 }
60 
61 inline void throw_number_of_columns_mismatch_error(size_t num_table_cols,
62  size_t num_file_cols,
63  const std::string& file_path) {
64  throw ForeignStorageException{"Mismatched number of logical columns: (expected " +
65  std::to_string(num_table_cols) + " columns, has " +
66  std::to_string(num_file_cols) + "): in file '" +
67  file_path + "'"};
68 }
69 
70 inline void throw_file_access_error(const std::string& file_path,
71  const std::string& message) {
72  std::string error_message{"Unable to access file \"" + file_path + "\". " + message};
73  throw ForeignStorageException{error_message};
74 }
75 
76 inline void throw_file_not_found_error(const std::string& file_path) {
77  throw ForeignStorageException{"File or directory \"" + file_path +
78  "\" does not exist."};
79 }
80 
81 inline void throw_s3_compressed_mime_type(const std::string& file_path,
82  const std::string& mime_type) {
84  "File \"" + file_path + "\" has mime type \"" + mime_type +
85  "\", compressed file formats are not supported by S3 Foreign Tables."};
86 }
87 
88 inline void throw_s3_compressed_extension(const std::string& file_path,
89  const std::string& ext_type) {
91  "File \"" + file_path + "\" has extension type \"" + ext_type +
92  "\", compressed file formats are not supported by S3 Foreign Tables."};
93 }
94 
95 } // namespace foreign_storage
void throw_file_access_error(const std::string &file_path, const std::string &message)
void throw_removed_row_in_file_error(const std::string &file_path)
void throw_file_not_found_error(const std::string &file_path)
std::string to_string(char const *&&v)
void throw_s3_compressed_extension(const std::string &file_path, const std::string &ext_type)
ForeignStorageException(const std::string &error_message)
void throw_removed_file_error(const std::string &file_path)
void throw_number_of_columns_mismatch_error(size_t num_table_cols, size_t num_file_cols, const std::string &file_path)
MetadataScanInfeasibleFragmentSizeException(const std::string &error_message)
void throw_s3_compressed_mime_type(const std::string &file_path, const std::string &mime_type)
void throw_removed_row_in_result_set_error(const std::string &select_statement)