X-Git-Url: https://git.saurik.com/cycript.git/blobdiff_plain/c1d3e52e58e86c49f9d04e06ae8e0ece4b98250c..824bc1ec28c62ea1d63622c46e1edfd911c38b64:/Exception.hpp diff --git a/Exception.hpp b/Exception.hpp index 0282f0f..4b97f83 100644 --- a/Exception.hpp +++ b/Exception.hpp @@ -35,13 +35,13 @@ class CYPool; -struct CYException { +struct _visible CYException { virtual ~CYException() { } virtual const char *PoolCString(CYPool &pool) const = 0; #ifdef CY_EXECUTE - virtual JSValueRef CastJSValue(JSContextRef context) const = 0; + virtual JSValueRef CastJSValue(JSContextRef context, const char *name) const = 0; #endif }; @@ -53,14 +53,16 @@ void CYThrow(JSContextRef context, JSValueRef value); #define CYTry \ try -#define CYCatch(value) \ +#define CYCatch_(value, name) \ catch (const CYException &error) { \ - *exception = error.CastJSValue(context); \ + *exception = error.CastJSValue(context, name); \ return value; \ } catch (...) { \ *exception = CYCastJSValue(context, "catch(...)"); \ return value; \ } +#define CYCatch(value) \ + CYCatch_(value, "Error") #define _assert_(mode, test, code, format, ...) do \ if (!(test)) \ @@ -78,7 +80,7 @@ while (false) _value; }) #define _trace() do { \ - fprintf(stderr, "_trace():%u\n", __LINE__); \ + fprintf(stderr, "_trace(%s:%u)\n", __FILE__, __LINE__); \ } while (false) static _finline bool CYContains(int value, size_t many, const int *okay) { @@ -105,9 +107,10 @@ static _finline bool CYContains(int value, size_t many, const int *okay) { #define _sqlcall(expr) ({ \ __typeof__(expr) _value = (expr); \ - _assert_("sqlcall", _value == 0 || _value >= 100 && _value < 200, #expr, " %u:%s", _value sqlite3_errmsg(database_)); \ -}) + _assert_("sqlcall", _value == 0 || _value >= 100 && _value < 200, #expr, " %u:%s", _value, sqlite3_errmsg(database_)); \ +_value; }) +#ifdef CY_EXECUTE struct CYJSException { JSContextRef context_; JSValueRef value_; @@ -131,5 +134,6 @@ struct CYJSException { CYJSException _error(context); \ (code)(args, _error); \ }) +#endif #endif/*CYCRIPT_ERROR_HPP*/