OmniSciDB  471d68cefb
 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 inline void throw_removed_row_error(const std::string& file_path) {
31  "Refresh of foreign table created with \"APPEND\" update type failed as file "
32  "reduced in size: " +
33  file_path};
34 }
35 
36 inline void throw_removed_file_error(const std::string& file_path) {
38  "Refresh of foreign table created with \"APPEND\" update type failed as "
39  "file \"" +
40  file_path + "\" was removed."};
41 }
42 
43 inline void throw_number_of_columns_mismatch_error(size_t num_table_cols,
44  size_t num_file_cols,
45  const std::string& file_path) {
46  throw ForeignStorageException{"Mismatched number of logical columns: (expected " +
47  std::to_string(num_table_cols) + " columns, has " +
48  std::to_string(num_file_cols) + "): in file '" +
49  file_path + "'"};
50 }
51 
52 inline void throw_file_access_error(const std::string& file_path,
53  const std::string& message) {
54  std::string error_message{"Unable to access file \"" + file_path + "\". " + message};
55  throw ForeignStorageException{error_message};
56 }
57 
58 inline void throw_file_not_found_error(const std::string& file_path) {
59  throw ForeignStorageException{"File or directory \"" + file_path +
60  "\" does not exist."};
61 }
62 } // namespace foreign_storage
void throw_file_access_error(const std::string &file_path, const std::string &message)
void throw_file_not_found_error(const std::string &file_path)
std::string to_string(char const *&&v)
void throw_removed_row_error(const std::string &file_path)
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)