userver: userver/storages/sqlite/exceptions.hpp Source File
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
exceptions.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file userver/storages/sqlite/exceptions.hpp
4
5#include <stdexcept>
6#include <string>
7
8USERVER_NAMESPACE_BEGIN
9
10namespace storages::sqlite {
11
12/// @brief Base class for all uSQLite driver exceptions
13class SQLiteException : public std::runtime_error {
14public:
15 SQLiteException(const char* error_message, int error_code, int extended_error_code);
16
17 SQLiteException(const std::string& error_message, int error_code, int extended_error_code);
18
19 SQLiteException(const char* error_message, int error_code);
20
21 SQLiteException(const std::string& error_message, int error_code);
22
23 explicit SQLiteException(const char* error_message);
24
25 explicit SQLiteException(const std::string& error_message);
26
27 ~SQLiteException() override;
28
29 /// Return the result code (if any, otherwise -1).
30 int getErrorCode() const noexcept;
31
32 /// Return the extended numeric result code (if any, otherwise -1).
33 int getExtendedErrorCode() const noexcept;
34
35 /// Return a string, solely based on the error code
36 const char* getErrorStr() const noexcept;
37
38private:
39 int error_code_; // Error code value
40 int extended_error_code_; // Detailed error code if any
41};
42
43} // namespace storages::sqlite
44
45USERVER_NAMESPACE_END