OmniSciDB  a987f07e93
 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 2022 HEAVY.AI, 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 #pragma once
18 
19 #include <stdexcept>
20 #include <string>
21 
22 namespace foreign_storage {
23 
24 class ForeignStorageException : public std::runtime_error {
25  public:
26  ForeignStorageException(const std::string& error_message)
27  : std::runtime_error(error_message) {}
28 };
29 
31  public:
32  MetadataScanInfeasibleFragmentSizeException(const std::string& error_message)
34 
35  int32_t
36  min_feasible_fragment_size_; // may be set to indicate what the minimum feasible
37  // fragment size for metadata scan should be
38 };
39 
40 inline void throw_unexpected_number_of_items(const size_t& num_expected,
41  const size_t& num_loaded,
42  const std::string& item_type) {
44  "Unexpected number of " + item_type +
45  " while loading from foreign data source: expected " +
46  std::to_string(num_expected) + " , obtained " + std::to_string(num_loaded) + " " +
47  item_type +
48  ". Please use the \"REFRESH FOREIGN TABLES\" command on the foreign table "
49  "if data source has been updated.");
50 }
51 
53  public:
54  RequestedFragmentIdOutOfBoundsException(const std::string& error_message)
55  : ForeignStorageException(error_message) {}
56 };
57 
58 inline void throw_removed_row_in_result_set_error(const std::string& select_statement) {
60  "Refresh of foreign table created with \"APPEND\" update type failed as result set "
61  "of select statement "
62  "reduced in size: \"" +
63  select_statement + "\""};
64 }
65 
66 inline void throw_removed_row_in_file_error(const std::string& file_path) {
68  "Refresh of foreign table created with \"APPEND\" update type failed as file "
69  "reduced in size: \"" +
70  file_path + "\""};
71 }
72 
73 inline void throw_removed_file_error(const std::string& file_path) {
75  "Refresh of foreign table created with \"APPEND\" update type failed as "
76  "file \"" +
77  file_path + "\" was removed."};
78 }
79 
80 inline void throw_number_of_columns_mismatch_error(size_t num_table_cols,
81  size_t num_file_cols,
82  const std::string& file_path) {
83  throw ForeignStorageException{"Mismatched number of logical columns: (expected " +
84  std::to_string(num_table_cols) + " columns, has " +
85  std::to_string(num_file_cols) + "): in file '" +
86  file_path + "'"};
87 }
88 
89 inline void throw_file_access_error(const std::string& file_path,
90  const std::string& message) {
91  std::string error_message{"Unable to access file \"" + file_path + "\". " + message};
92  throw ForeignStorageException{error_message};
93 }
94 
95 inline void throw_file_not_found_error(const std::string& file_path) {
96  throw ForeignStorageException{"File or directory \"" + file_path +
97  "\" does not exist."};
98 }
99 
100 inline void throw_s3_compressed_mime_type(const std::string& file_path,
101  const std::string& mime_type) {
103  "File \"" + file_path + "\" has mime type \"" + mime_type +
104  "\", compressed file formats are not supported by S3 Foreign Tables."};
105 }
106 
107 inline void throw_s3_compressed_extension(const std::string& file_path,
108  const std::string& ext_type) {
110  "File \"" + file_path + "\" has extension type \"" + ext_type +
111  "\", compressed file formats are not supported by S3 Foreign Tables."};
112 }
113 
114 } // 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)
RequestedFragmentIdOutOfBoundsException(const std::string &error_message)
void throw_s3_compressed_mime_type(const std::string &file_path, const std::string &mime_type)
void throw_unexpected_number_of_items(const size_t &num_expected, const size_t &num_loaded, const std::string &item_type)
void throw_removed_row_in_result_set_error(const std::string &select_statement)