Fray Engine
Loading...
Searching...
No Matches
errors.hpp
Go to the documentation of this file.
1/* error.hpp */
2
3#ifndef _FRAY_ERRORS_HPP_
4#define _FRAY_ERRORS_HPP_
5
6#include <cstdio>
7
8#include "types.hpp"
9
13typedef F_long F_err;
14
15namespace fray
16{
17 namespace errors
18 {
19
34#define FRAY_ERROR_LIST \
35 X(NONE, "No error.") \
36 X(FLAG_1, "Flag 1 error.") \
37 X(FLAG_2, "Flag 2 error.") \
38 X(FLAG_3, "Flag 3 error.") \
39 X(FLAG_4, "Flag 4 error.") \
40 X(FLAG_5, "Flag 5 error.") \
41 X(FLAG_6, "Flag 6 error.") \
42 X(FLAG_7, "Flag 7 error.") \
43 X(FLAG_8, "Flag 8 error.") \
44 X(FLAG_9, "Flag 9 error.") \
45 X(GENERAL, "General error.") \
46 X(FAILED_SET_STATE, "Failed to update the state.") \
47 X(INVALID_APPLICATION_ID, "Could not set the state application ID.") \
48 X(NO_MESSAGE_ROUTER, "The TCP server's message router has not been set.") \
49 X(FAILED_START, "Failed to start the engine process.") \
50 X(FAILED_OPEN_STORE, "Failed to open the store.") \
51 X(FAILED_SAVE_STATE, "Failed to save the state.") \
52 X(FAILED_LOAD_STATE, "Failed to load the state.") \
53 X(STATE_NOT_FOUND, "State key does not exist.") \
54 X(INVALID_STATE_KEY, "The state key is invalid.") \
55 X(STATE_TYPE_MISMATCH, "The state value has a different type.") \
56 X(STATE_VALUE_OUT_OF_RANGE, "The state value is outside the supported range.") \
57 X(FAILED_REMOVE_STATE, "Failed to remove state.") \
58 X(FAILED_CLOSE_STORE, "Failed to close the store.") \
59 X(FAILED_HISTORY, "Failed to read or write the project history.") \
60 X(FAILED_RENAME_STATE_TABLE, "Failed to rename the state table.") \
61 X(FAILED_OPEN_PROJECT, "Failed to open the project.") \
62 X(FAILED_SAVE_PROJECT, "Failed to save the project.") \
63 X(FAILED_CLOSE_PROJECT, "Failed to close the project.") \
64 X(PROJECT_CONFLICT, "Both the project archive and working folder exist.") \
65 X(PROJECT_ALREADY_OPEN, "This project is already open.") \
66 X(DATABASE_CONFLICT, "Multiple database files could be the project database.") \
67 X(FAILED_RENAME_PROJECT, "Failed to rename the project.") \
68 X(FAILED_SPAWN_PROCESS, "Failed to spawn the process.") \
69 X(INVALID_MESSAGE, "The message is malformed.") \
70 X(MESSAGE_TOO_LARGE, "The message exceeds the maximum frame size.") \
71 X(UNSUPPORTED_MESSAGE_VERSION, "The message prefix version is not supported.") \
72 X(PROJECT_FOLDER_EXISTS, "A project folder already exists.") \
73 X(PROJECT_ARCHIVE_EXISTS, "A project archive already exists.") \
74 X(PROJECT_BOTH_EXIST, "A project folder and archive already exist.") \
75 X(PROJECT_NOT_FOUND, "The selected project does not exist.") \
76 X(INVALID_PROJECT_DATABASE, "The selected project has no valid Fray database.") \
77 X(PROJECT_DATABASE_OCCUPIED, "A project database path is already occupied.") \
78 X(PROJECT_AMBIGUOUS, "Multiple open projects have this name; use the full path.")
79
83 enum code : F_err
84 {
85#define X(name, desc) name,
87#undef X
88 };
89
96 inline const F_char *description(
97 code err)
98 {
99 static F_char buffer[128];
100 switch (err)
101 {
102#define X(name, desc) \
103 case code::name: \
104 snprintf(buffer, sizeof(buffer), "Error %lld: %s", static_cast<F_longlong>(code::name), desc); \
105 return buffer;
107#undef X
108 default:
109 snprintf(buffer, sizeof(buffer), "Error %lld: %s", static_cast<F_longlong>(err), "Unknown error.");
110 return buffer;
111 }
112 }
113
119 inline const F_char *description(
120 F_err err)
121 {
122 return description(static_cast<code>(err));
123 }
124
125 }
126}
127
128#endif
F_long F_err
Error return type used across the Engine; the value is a fray::errors::code (0 / NONE means success).
Definition errors.hpp:13
code
All Engine error codes, generated from FRAY_ERROR_LIST. NONE is 0 and means success.
Definition errors.hpp:84
@ FRAY_ERROR_LIST
Definition errors.hpp:86
const F_char * description(code err)
Formats an error code as "Error <number>: <description>". Not thread-safe: the text lives in a shared...
Definition errors.hpp:96
int64_t F_longlong
Signed 64-bit integer.
Definition types.hpp:38
int32_t F_long
Signed 32-bit integer (also the base of F_err).
Definition types.hpp:32
char F_char
Alias for char.
Definition types.hpp:24