feat: add comprehensive error handling with typed error codes
Add strict error handling for stk initialization and platform operations. stk_init() now fails fast on critical errors and returns typed error codes that users can handle programmatically. Changes: - Add STK_INIT_* error codes for init failures (memory, tmpdir, watch) - Add STK_PLATFORM_* error codes for platform operation results - Check platform_mkdir() and fail if temp directory cannot be created - Check platform_directory_watch_start() and fail if watch cannot initialize - Add error_cleanup path in platform_directory_watch_start() to properly free resources on critical Windows failures. - Replace all platform error checks with STK_PLATFORM_OPERATION_SUCCESS - Log FATAL errors with when critical operations fail - Add warning logs for non-critical failures Critical failures now return specific error codes: - STK_INIT_MEMORY_ERROR: Module memory allocation failed - STK_INIT_TMPDIR_ERROR: Cannot create temp directory - STK_INIT_WATCH_ERROR: Cannot start directory watching Individual module load failures remain non-fatal and are handled logged.
This commit is contained in:
+14
-1
@@ -10,12 +10,25 @@
|
||||
#define STK_PATH_MAX 256
|
||||
#define STK_PATH_MAX_OS 4096
|
||||
|
||||
/* Modules */
|
||||
/* Initialization return codes */
|
||||
#define STK_INIT_SUCCESS 0
|
||||
#define STK_INIT_MEMORY_ERROR 1
|
||||
#define STK_INIT_TMPDIR_ERROR 2
|
||||
#define STK_INIT_WATCH_ERROR 3
|
||||
|
||||
/* Module loading return codes */
|
||||
#define STK_MOD_INIT_SUCCESS 0
|
||||
#define STK_MOD_INIT_FAILURE 1
|
||||
#define STK_MOD_LIBRARY_LOAD_ERROR 2
|
||||
#define STK_MOD_SYMBOL_NOT_FOUND_ERROR 3
|
||||
|
||||
/* Platform return codes */
|
||||
#define STK_PLATFORM_OPERATION_SUCCESS 0
|
||||
#define STK_PLATFORM_FILE_COPY_ERROR 1
|
||||
#define STK_PLATFORM_MKDIR_ERROR 2
|
||||
#define STK_PLATFORM_REMOVE_DIR_ERROR 3
|
||||
#define STK_PLATFORM_REMOVE_FILE_ERROR 4
|
||||
|
||||
#if defined(__linux__) || defined(_WIN32)
|
||||
#define STK_EVENT_BUFFER 4096
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user