Atlas Game Manager
A game manager for f95 and dlsite written in c++
Loading...
Searching...
No Matches
exceptions.hpp
Go to the documentation of this file.
1//
2// Created by kj16609 on 9/18/23.
3//
4
5#pragma once
6#ifndef ATLASGAMEMANAGER_EXCEPTIONS_HPP
7#define ATLASGAMEMANAGER_EXCEPTIONS_HPP
8
9#include <exception>
10#include <source_location>
11
13
15{
16 struct AtlasException : public std::runtime_error
17 {
18 std::source_location sloc;
19 std::string what_text;
20
21 virtual const char* what() const noexcept override { return what_text.c_str(); }
22
24 const char* whatRaw() const noexcept { return std::runtime_error::what(); }
25
26 AtlasException( const char* const msg, const std::source_location loc = std::source_location::current() ) :
27 std::runtime_error( msg ),
28 sloc( loc ),
29 what_text( format_ns::format( "{}: {}", sloc, std::runtime_error::what() ) )
30 {
31 atlas::logging::errorLoc( "{}", loc, msg );
32 }
33
34 AtlasException( const std::string msg, const std::source_location loc = std::source_location::current() ) :
35 AtlasException( msg.c_str(), loc )
36 {}
37 };
38
40 {
41 RecordException( const char* const msg, const std::source_location loc = std::source_location::current() ) :
42 AtlasException( msg, loc )
43 {}
44 };
45
47 {
49 QString m_version;
50
52 const char* const msg,
53 const RecordID game_id,
54 const QString version,
55 const std::source_location loc = std::source_location::current() ) :
56 RecordException( msg, loc ),
57 m_game_id( game_id ),
58 m_version( version )
59 {}
60 };
61
63 {
64 DatabaseException( const char* const msg, const std::source_location loc = std::source_location::current() ) :
65 AtlasException( msg, loc )
66 {}
67
68 DatabaseException( std::string msg, std::source_location loc = std::source_location::current() ) :
69 DatabaseException( msg.c_str(), loc )
70 {}
71 };
72
74 {
75 DatabaseRowMismatch( const char* const msg, const std::source_location loc = std::source_location::current() ) :
76 DatabaseException( msg, loc )
77 {}
78
79 DatabaseRowMismatch( std::string msg, std::source_location loc = std::source_location::current() ) :
80 DatabaseException( msg.c_str(), loc )
81 {}
82 };
83
85 {
86 ImportException( const char* const msg, const std::source_location loc = std::source_location::current() ) :
87 AtlasException( msg, loc )
88 {}
89 };
90
92 {
93 NoExecutablesFound( std::filesystem::path folder, std::source_location loc = std::source_location::current() ) :
94 ImportException( format_ns::format( "No valid executables found for directory: {}", folder ).c_str(), loc )
95 {}
96 };
97
99 {
101 const char* const m_sql_string, const std::source_location loc = std::source_location::current() ) :
103 format_ns::format( "Transaction accessed while invalid: Last executed: {}", m_sql_string ), loc )
104 {}
105 };
106
108 {
109 SettingsException( const char* const msg, const std::source_location loc = std::source_location::current() ) :
110 AtlasException( msg, loc )
111 {}
112 };
113
114} // namespace atlas::exceptions
115
116using namespace atlas::exceptions;
117
118#endif //ATLASGAMEMANAGER_EXCEPTIONS_HPP
std::uint32_t RecordID
Definition Types.hpp:11
Definition exceptions.hpp:15
errorLoc(format_ns::format_string< Ts... >, const std::source_location &, Ts &&... a) -> errorLoc< Ts... >
AtlasException(const std::string msg, const std::source_location loc=std::source_location::current())
Definition exceptions.hpp:34
std::string what_text
Definition exceptions.hpp:19
AtlasException(const char *const msg, const std::source_location loc=std::source_location::current())
Definition exceptions.hpp:26
const char * whatRaw() const noexcept
Returns the what() message without any source location info.
Definition exceptions.hpp:24
std::source_location sloc
Definition exceptions.hpp:18
virtual const char * what() const noexcept override
Definition exceptions.hpp:21
DatabaseException(const char *const msg, const std::source_location loc=std::source_location::current())
Definition exceptions.hpp:64
DatabaseException(std::string msg, std::source_location loc=std::source_location::current())
Definition exceptions.hpp:68
DatabaseRowMismatch(std::string msg, std::source_location loc=std::source_location::current())
Definition exceptions.hpp:79
DatabaseRowMismatch(const char *const msg, const std::source_location loc=std::source_location::current())
Definition exceptions.hpp:75
ImportException(const char *const msg, const std::source_location loc=std::source_location::current())
Definition exceptions.hpp:86
NoExecutablesFound(std::filesystem::path folder, std::source_location loc=std::source_location::current())
Definition exceptions.hpp:93
RecordException(const char *const msg, const std::source_location loc=std::source_location::current())
Definition exceptions.hpp:41
SettingsException(const char *const msg, const std::source_location loc=std::source_location::current())
Definition exceptions.hpp:109
TransactionInvalid(const char *const m_sql_string, const std::source_location loc=std::source_location::current())
Definition exceptions.hpp:100
RecordID m_game_id
Definition exceptions.hpp:48
QString m_version
Definition exceptions.hpp:49
VersionConflict(const char *const msg, const RecordID game_id, const QString version, const std::source_location loc=std::source_location::current())
Definition exceptions.hpp:51