libikarus/include/ikarus/errors.h
Folling f847d30c06
implement toggle/number/text values
Signed-off-by: Folling <mail@folling.io>
2025-04-15 12:08:00 +02:00

71 lines
3.3 KiB
C

#pragma once
/// \file global.h
/// \author Folling <folling@ikarus.world>
#include <ikarus/macros.h>
/// \addtogroup errors Errors
/// \brief Error handling within libikarus
/// \details Errors are stored for each project, akin to the errno handling in C.
/// We store multiple pieces of information about the error occurring. For more information see
/// #ikarus_project_get_error_message.
/// @{
IKARUS_BEGIN_HEADER
/// \brief Delineates what caused an error.
/// \details First 2 bytes delineate the major type, next 2 bytes delineate the minor type, next 4 bytes delineate the detail
/// type.
/// \remark Note that this doesn't show responsibility. An error with source "SubSystem" could still be the fault of
/// libikarus.
enum IkarusErrorInfo {
/// \brief No error occurred.
IkarusErrorInfo_Source_None = 0x0001000000000000,
/// \brief The error was caused by the client.
IkarusErrorInfo_Source_Client = 0x0001000000000001,
/// \brief The error was caused by a sub-system of libikarus.
IkarusErrorInfo_Source_SubSystem = 0x0001000000000002,
/// \brief The error was caused by libikarus itself.
IkarusErrorInfo_Source_LibIkarus = 0x0001000000000003,
/// \brief The error was caused by an unknown source.
IkarusErrorInfo_Source_Unknown = 0x00010000FFFFFFFF,
/// \brief No error occurred.
IkarusErrorInfo_Type_None = 0x0002000000000000,
/// \brief The user misused the API.
/// Example: Accessing a resource that does not exist.
IkarusErrorInfo_Type_Client_Misuse = 0x0002000100000001,
/// \brief The user provided invalid input.
/// Example: Passing null for a pointer that must not be null.
IkarusErrorInfo_Type_Client_Input = 0x0002000100000002,
/// \brief An error occurred while interacting with a dependency from ikarus.
/// Example: An error occurred in the underlying OS library.
IkarusErrorInfo_Type_SubSystem_Dependency = 0x0002000200000001,
/// \brief An error occurred while interacting with the database.
/// Example: An error occurred while executing a query.
IkarusErrorInfo_Type_SubSystem_Database = 0x0002000200000002,
/// \brief An error occurred while interacting with the filesystem.
/// Example: An error occurred while reading a file.
IkarusErrorInfo_Type_SubSystem_Filesystem = 0x0002000200000003,
/// \brief A datapoint within ikarus is invalid for the current state of the system.
/// Example: The name of an object is found to be invalid UTF8.
IkarusErrorInfo_Type_LibIkarus_InvalidState = 0x0002000300000001,
/// \brief LibIkarus is unable to perform a certain operation that should succeed.
/// Example: Migrating a project fails
IkarusErrorInfo_Type_LibIkarus_CannotPerformOperation = 0x0002000300000002,
/// \brief LibIkarus is unable to perform a certain operation within a given timeframe.
/// Example: A query takes longer than the timeout.
IkarusErrorInfo_Type_LibIkarus_Timeout = 0x0002000300000003,
/// \brief The type of error is unknown.
IkarusErrorInfo_Type_Unknown = 0xFFFFFFFF,
};
/// \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 * get_error_info_name(IkarusErrorInfo info);
IKARUS_END_HEADER
/// @}