diff options
author | bptato <nincsnevem662@gmail.com> | 2025-03-07 18:44:27 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2025-03-07 19:16:43 +0100 |
commit | e3ba07dec774d6c05a2397c8c50797ef6f56286e (patch) | |
tree | a09bde891889269299bcc7806c149d9b9980bc35 /src/config/config.nim | |
parent | 6d904b63955573e3346afc075b48645166531bd9 (diff) | |
download | chawan-e3ba07dec774d6c05a2397c8c50797ef6f56286e.tar.gz |
tojs: misc cleanup
* optimize toJS set * change defineProperty wrappers to return an enum If we're going to wrap defineProperty, then let's do it properly.
Diffstat (limited to 'src/config/config.nim')
-rw-r--r-- | src/config/config.nim | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/config/config.nim b/src/config/config.nim index 3909e46c..0dbc6877 100644 --- a/src/config/config.nim +++ b/src/config/config.nim @@ -826,7 +826,9 @@ proc initCommands*(config: Config): Err[string] = var prop = JS_GetPropertyStr(ctx, objIt, cstring(ss)) if JS_IsUndefined(prop): prop = JS_NewObject(ctx) - ctx.definePropertyE(objIt, ss, JS_DupValue(ctx, prop)) + case ctx.definePropertyE(objIt, ss, JS_DupValue(ctx, prop)) + of dprException: return err(ctx.getExceptionMsg()) + else: discard if JS_IsException(prop): return err(ctx.getExceptionMsg()) JS_FreeValue(ctx, objIt) @@ -840,7 +842,9 @@ proc initCommands*(config: Config): Err[string] = if not JS_IsFunction(ctx, fun): JS_FreeValue(ctx, fun) return err(k & " is not a function") - ctx.definePropertyE(objIt, name, JS_DupValue(ctx, fun)) + case ctx.definePropertyE(objIt, name, JS_DupValue(ctx, fun)) + of dprException: return err(ctx.getExceptionMsg()) + else: discard config.cmd.map[k] = fun JS_FreeValue(ctx, objIt) config.cmd.jsObj = JS_DupValue(ctx, obj) |