bool comma(false);
for (size_t index(0), count(CYCastDouble(context, length)); index != count; ++index) {
- JSValueRef value(CYGetProperty(context, _this, index));
-
if (comma)
str << ',';
else
comma = true;
- if (!JSValueIsUndefined(context, value))
- str << CYPoolCCYON(pool, context, value);
- else {
- str << ',';
- comma = false;
+ try {
+ JSValueRef value(CYGetProperty(context, _this, index));
+ if (!JSValueIsUndefined(context, value))
+ str << CYPoolCCYON(pool, context, value);
+ else {
+ str << ',';
+ comma = false;
+ }
+ } catch (const CYException &error) {
+ str << "@error";
}
}
const char *CYExecute(CYPool &pool, CYUTF8String code) {
JSContextRef context(CYGetJSContext());
- JSValueRef exception(NULL), result;
+ JSValueRef exception(NULL);
void *handle;
if (hooks_ != NULL && hooks_->ExecuteStart != NULL)
else
handle = NULL;
- const char *json;
+ try {
+ JSValueRef result;
try {
result = JSEvaluateScript(context, CYJSString(code), NULL, NULL, 0, &exception);
} catch (const char *error) {
if (JSValueIsUndefined(context, result))
return NULL;
+ const char *json;
try {
json = CYPoolCCYON(pool, context, result, &exception);
} catch (const char *error) {
CYSetProperty(context, CYGetGlobalObject(context), Result_, result);
- if (hooks_ != NULL && hooks_->ExecuteEnd != NULL)
- (*hooks_->ExecuteEnd)(context, handle);
return json;
+
+ } catch (...) {
+ if (hooks_ != NULL && hooks_->ExecuteEnd != NULL)
+ (*hooks_->ExecuteEnd)(context, handle);
+ throw;
+ }
}
extern "C" void CydgetSetupContext(JSGlobalContextRef context) {