finalize schema/data setup

Signed-off-by: Folling <mail@folling.io>
This commit is contained in:
folling 2025-01-01 13:49:05 +01:00 committed by Folling
parent 4d7bf09c4e
commit 954b8a11a3
Signed by: folling
SSH key fingerprint: SHA256:S9qEx5WCFFLK49tE/LKnKuJYM5sw+++Dn6qJbbyxnCY
89 changed files with 2324 additions and 6271 deletions

View file

@ -1,19 +1,17 @@
#pragma once
/// \file errors.h
/// \author Folling <folling@ikarus.world>
/// \author Folling <mail@folling.io>
#include <ikarus/macros.h>
/// \addtogroup errors Errors
/// \brief Error handling within libikarus
/// \details Functions in Ikarus may fail. To report the type of failure all functions have an out parameter for the error.
/// Upon erring the function will store relevant information about the error in the out parameter.
/// If the out parameter is null nothing will be stored. This is not recommended as it essentially ignores errors.
/// For the sake of simplicity we have avoided mechanisms that "force" clients to handle errors.
/// Note that Ikarus does not check for null pointers. Passing null pointers to functions that do not explicitly state that they accept null
/// pointers is undefined behaviour. This decision is done for the sake of brevity and readability. `project_get_name(project)` is also
/// synonymous to `project->get_name()` in OOP languages, which shares the same semantics.
/// Upon erring the function will store relevant information about the error in
/// the out parameter. If the out parameter is null nothing will be stored. This
/// is not recommended as it essentially ignores errors. For the sake of
/// simplicity we have avoided mechanisms that "force" clients to handle errors.
/// @{
IKARUS_BEGIN_HEADER
@ -22,73 +20,77 @@ IKARUS_BEGIN_HEADER
/// \remark Note that this doesn't show responsibility. An error with source "SubSystem" could still be the
/// fault of libikarus, it just indicates where the error occurred.
enum IkarusErrorInfo {
/// \brief No error occurred.
IkarusErrorInfo_None = 0x0,
/// \brief The client misused the API.
/// Example: Accessing a resource that does not exist.
IkarusErrorInfo_Client_Misuse = 0x01000001,
/// \brief The client provided a null value for a parameter that must not be null.
/// Example: Passing null for `ikarus_project_get_name`
IkarusErrorInfo_Client_InvalidNull = 0x01000002,
/// \brief The client provided an index that was out of bounds for some array.
/// Example: Passing the index 3 for an `IkarusToggleValue` with size 3.
IkarusErrorInfo_Client_IndexOutOfBounds = 0x01000003,
/// \brief The client provided a numeric value that was out of bounds
/// Example: Passing the value 2^32 to an i32 (might be passed as a string).
IkarusErrorInfo_Client_ValueOutOfBounds = 0x01000004,
/// \brief The client provided invalid input that doesn't fit in any of the other categories.
/// Example: Passing an empty/blank string for a string that must be non-empty/-blank.
IkarusErrorInfo_Client_InvalidInput = 0x01000005,
/// \brief The client provided valid data in an invalid format.
/// Example: Passing a malformed JSON string.
IkarusErrorInfo_Client_InvalidFormat = 0x01000006,
/// \brief The client violated a constraint.
/// \details This error is most likely caused by endusers.
/// Example: A user tries to set the age of a character to an value outside of their specified range.
IkarusErrorInfo_Client_ConstraintViolated = 0x10000007,
/// \brief No error occurred.
IkarusErrorInfo_None = 0x0,
/// \brief The client misused the API.
/// Example: Accessing a resource that does not exist.
IkarusErrorInfo_Client_Misuse = 0x01000001,
/// \brief The client provided a null value for a parameter that must not be null.
/// Example: Passing null for `ikarus_project_get_name`
IkarusErrorInfo_Client_InvalidNull = 0x01000002,
/// \brief The client provided a non-existent resource.
/// Example: Passing an entity to a function after it has been deleted.
IkarusErrorInfo_Client_NonExistent = 0x01000003,
/// \brief The client provided an index that was out of bounds for some array.
/// Example: Passing the index 3 for an `IkarusToggleValue` with size 3.
IkarusErrorInfo_Client_IndexOutOfBounds = 0x01000004,
/// \brief The client provided a numeric value that was out of bounds
/// Example: Passing the value 2^32 to an i32 (might be passed as a string).
IkarusErrorInfo_Client_ValueOutOfBounds = 0x01000005,
/// \brief The client provided invalid input that doesn't fit in any of the other categories.
/// Example: Passing an empty/blank string for a string that must be
/// non-empty/-blank.
IkarusErrorInfo_Client_InvalidInput = 0x01000006,
/// \brief The client provided valid data in an invalid format.
/// Example: Passing a malformed JSON string.
IkarusErrorInfo_Client_InvalidFormat = 0x01000007,
/// \brief The client violated a constraint.
/// \details This error is most likely caused by clients.
/// Example: A user tries to set the age of a character to a value outside
/// its specified range.
IkarusErrorInfo_Client_ConstraintViolated = 0x10000008,
// 0x02 reserved for dependency errors
// 0x02 reserved for dependency errors
/// \brief A file or directory already exists.
IkarusErrorInfo_Filesystem_AccessIssue = 0x03000001,
/// \brief A file was not found.
IkarusErrorInfo_Filesystem_NotFound = 0x03000002,
/// \brief A file or directory already exists.
IkarusErrorInfo_Filesystem_AlreadyExists = 0x03000003,
/// \brief Missing permissions to access a file or directory.
IkarusErrorInfo_Filesystem_MissingPermissions = 0x03000004,
/// \brief Insufficient space to perform an operation.
IkarusErrorInfo_Filesystem_InsufficientSpace = 0x03000005,
/// \brief A path is invalid.
IkarusErrorInfo_Filesystem_InvalidPath = 0x03000006,
/// \brief A file was not found.
IkarusErrorInfo_Filesystem_NotFound = 0x03000001,
/// \brief A file or directory already exists.
IkarusErrorInfo_Filesystem_AlreadyExists = 0x03000002,
/// \brief Missing permissions to access a file or directory.
IkarusErrorInfo_Filesystem_MissingPermissions = 0x03000003,
/// \brief Insufficient space to perform an operation.
IkarusErrorInfo_Filesystem_InsufficientSpace = 0x03000004,
/// \brief A path is invalid.
IkarusErrorInfo_Filesystem_InvalidPath = 0x03000005,
/// \brief A database connection failed.
IkarusErrorInfo_Database_ConnectionFailed = 0x04000001,
/// \brief A database query failed.
IkarusErrorInfo_Database_QueryFailed = 0x04000002,
/// \brief A database migration failed.
IkarusErrorInfo_Database_MigrationFailed = 0x04000003,
/// \brief A database is in an invalid state. This indicates a corrupt project.
/// Example: An entity is linked to a non-existant blueprint.
IkarusErrorInfo_Database_InvalidState = 0x04000004,
/// \brief A database connection failed.
IkarusErrorInfo_Database_ConnectionFailed = 0x04000001,
/// \brief A database query failed.
IkarusErrorInfo_Database_QueryFailed = 0x04000002,
/// \brief A database migration failed.
IkarusErrorInfo_Database_MigrationFailed = 0x04000003,
/// \brief A database is in an invalid state. This indicates a corrupt project.
/// Example: An entity is linked to a non-existent blueprint.
IkarusErrorInfo_Database_InvalidState = 0x04000004,
/// \brief A system call failed.
IkarusErrorInfo_OS_SystemCallFailed = 0x05000001,
/// \brief A system call returned an invalid value.
IkarusErrorInfo_OS_InvalidReturnValue = 0x05000002,
/// \brief An OOM error occurred.
IkarusErrorInfo_OS_InsufficientMemory = 0x05000003,
/// \brief A system call failed.
IkarusErrorInfo_OS_SystemCallFailed = 0x05000001,
/// \brief A system call returned an invalid value.
IkarusErrorInfo_OS_InvalidReturnValue = 0x05000002,
/// \brief An OOM error occurred.
IkarusErrorInfo_OS_InsufficientMemory = 0x05000003,
/// \brief A datapoint within ikarus is invalid for the current state of the system.
/// \details This differs from IkarusErrorInfo_Database_InvalidState in that the latter implies the database itself holds invalid state,
/// whereas the former may imply that the state is ephemeral, e.g. data within a function.
/// Example: The name of an object is found to be invalid UTF8.
IkarusErrorInfo_LibIkarus_InvalidState = 0x06000001,
/// \brief libikarus is unable to perform a certain operation that should succeed.
IkarusErrorInfo_LibIkarus_CannotPerformOperation = 0x06000002,
/// \brief libikarus is unable to perform a certain operation within a given timeframe.
/// Example: A query takes longer than the timeout.
IkarusErrorInfo_LibIkarus_Timeout = 0x06000003,
/// \brief A datapoint within ikarus is invalid for the current state of the system.
/// \details This differs from IkarusErrorInfo_Database_InvalidState in that the latter implies the database itself holds invalid state,
/// whereas the former may imply that the state is ephemeral, e.g. data
/// within a function.
/// Example: The name of an object is found to be invalid UTF8.
IkarusErrorInfo_LibIkarus_InvalidState = 0x06000001,
/// \brief libikarus is unable to perform a certain operation that should succeed.
IkarusErrorInfo_LibIkarus_CannotPerformOperation = 0x06000002,
/// \brief libikarus is unable to perform a certain operation within a given timeframe.
/// Example: A query takes longer than the timeout.
IkarusErrorInfo_LibIkarus_Timeout = 0x06000003,
};
/// \brief The maximum length of an error message.
@ -96,17 +98,17 @@ enum IkarusErrorInfo {
/// \brief The data stored for an error
struct IkarusErrorData {
/// \brief The error type
IkarusErrorInfo info;
/// \brief The error type
enum IkarusErrorInfo info;
char message[IKARUS_ERROR_DATA_MAX_MESSAGE_LIMIT];
char message[IKARUS_ERROR_DATA_MAX_MESSAGE_LIMIT];
};
/// \brief Gets the name of an error info.
/// \param info The error info to get the name of.
/// \return The name of the error info.
/// \remark The returned pointer is valid for the lifetime of the program and must not be freed.
IKA_API char const * ikarus_get_error_info_name(IkarusErrorInfo info);
IKA_API char const * ikarus_error_info_get_name(enum IkarusErrorInfo info);
/// \brief Checks if an error data is a success.
/// \param data The error data to check.