ну например)) TRY(res)
{
THROW_RES( fs_file_open( sys_fs(), FS_READ, (const char*)fname, &hwfile ) );
...
} CATCH {
result = res;
}
TRY_END;
//---------------------------------
#define TRY(code) {\
volatile result_t code = RES_NO_ERROR; \
volatile result_t* __pcode__ = &code; \
vu32 __lr__ = 0; \
rn_setjmp(&__lr__); \
switch( code ) \
if(0) case 0:
#define CATCH \
else default:
#define TRY_END }
#define THROW(code) \
do { \
*__pcode__ = code; \
rn_longjmp(&__lr__);\
} while(0)
для дебага можно и так сделать
#define THROW_RES(f) do { result_t __exc_res; if( (__exc_res = f) != RES_NO_ERROR ) \
{ RN_LOG_ERROR(HANDLE_NULL, "Exception (%s): file %s line %d", result_str(__exc_res), __FILE__, __LINE__); THROW( __exc_res ); } } while(0)