StormByte C++ Library: Database module 0.0.9999
StormByte-Database is a StormByte library module for handling database connections
Loading...
Searching...
No Matches
exception.hxx
1#pragma once
2
3#include <StormByte/exception.hxx>
4#include <StormByte/database/visibility.h>
5
10namespace StormByte::Database {
15 class STORMBYTE_DATABASE_PUBLIC Exception: public StormByte::Exception {
16 public:
17 template <typename... Args>
18 Exception(const std::string& component, std::format_string<Args...> fmt, Args&&... args):
19 StormByte::Exception("Database::" + component, fmt, std::forward<Args>(args)...) {}
20
21 using StormByte::Exception::Exception;
22
26 virtual ~Exception() noexcept override = default;
27 };
28
33 class STORMBYTE_DATABASE_PUBLIC ConnectionError final: public Exception {
34 public:
35 ConnectionError(const std::string& error):
36 Exception("Connection: ", error) {}
37
38 using Exception::Exception;
39 };
40
45 class STORMBYTE_DATABASE_PUBLIC WrongValueType final: public Exception {
46 public:
47 template <typename... Args>
48 WrongValueType(const std::string& component, std::format_string<Args...> fmt, Args&&... args):
49 Exception("WrongValueType: ", fmt, std::forward<Args>(args)...) {}
50
51 using Exception::Exception;
52 };
53
58 class STORMBYTE_DATABASE_PUBLIC ColumnNotFound: public Exception {
59 public:
60 template <typename... Args>
61 ColumnNotFound(const std::string& collumn):
62 Exception("ColumnNotFound: ", "Column '{}' not found", collumn) {}
63
64 using Exception::Exception;
65 };
66
71 class STORMBYTE_DATABASE_PUBLIC OutOfBounds: public Exception {
72 public:
73 OutOfBounds(int pos, std::size_t size):
74 Exception("OutOfBounds: ", "Position {} is out of bounds for size {}", pos, size) {}
75
76 using Exception::Exception;
77 };
78
83 class STORMBYTE_DATABASE_PUBLIC QueryException: public Exception {
84 public:
85 template <typename... Args>
86 QueryException(const std::string& component, std::format_string<Args...> fmt, Args&&... args):
87 Exception("Query::" + component, fmt, std::forward<Args>(args)...) {}
88
89 using Exception::Exception;
90 };
91
96 class STORMBYTE_DATABASE_PUBLIC UnknownSTMT: public QueryException {
97 public:
98 UnknownSTMT(const std::string& name):
99 QueryException("PreparedSTMT: ", "Statement '{}' not found", name) {}
100
101 using QueryException::QueryException;
102 };
103
108 class STORMBYTE_DATABASE_PUBLIC ExecuteError: public QueryException {
109 public:
110 ExecuteError(const std::string& error):
111 QueryException("Execute: ", "Error executing query: {}", error) {}
112
113 using QueryException::QueryException;
114 };
115}
Exception when accessing a not found column.
Definition exception.hxx:58
Definition exception.hxx:33
Base class for Database exceptions.
Definition exception.hxx:15
virtual ~Exception() noexcept override=default
Exception when executing a query.
Definition exception.hxx:108
Exception when accessing an out of bounds column.
Definition exception.hxx:71
Exception related to query execution.
Definition exception.hxx:83
Exception when accessing an unknown prepared statement.
Definition exception.hxx:96
Exception thrown when value type requested is not correct.
Definition exception.hxx:45