// retoor #ifndef R_ERROR_H #define R_ERROR_H typedef enum { R_SUCCESS = 0, R_ERROR_INVALID_ARG, R_ERROR_OUT_OF_MEMORY, R_ERROR_NOT_FOUND, R_ERROR_PARSE, R_ERROR_DB_CONNECTION, R_ERROR_DB_QUERY, R_ERROR_DB_NOT_FOUND, R_ERROR_HTTP_CONNECTION, R_ERROR_HTTP_TIMEOUT, R_ERROR_HTTP_RESPONSE, R_ERROR_JSON_PARSE, R_ERROR_FILE_NOT_FOUND, R_ERROR_FILE_READ, R_ERROR_FILE_WRITE, R_ERROR_TOOL_NOT_FOUND, R_ERROR_TOOL_EXECUTION, R_ERROR_API_KEY_MISSING, R_ERROR_API_ERROR, R_ERROR_CONTEXT_TOO_LONG, R_ERROR_MAX_ITERATIONS, R_ERROR_SESSION_INVALID, R_ERROR_UNKNOWN } r_status_t; const char *r_status_string(r_status_t status); #define R_CHECK(expr) do { r_status_t _s = (expr); if (_s != R_SUCCESS) return _s; } while(0) #define R_CHECK_NULL(ptr) do { if (!(ptr)) return R_ERROR_INVALID_ARG; } while(0) #define R_CHECK_ALLOC(ptr) do { if (!(ptr)) return R_ERROR_OUT_OF_MEMORY; } while(0) #endif