aboutsummaryrefslogtreecommitdiff
path: root/nginx/ngx_http_js_module.c
diff options
context:
space:
mode:
authorDmitry Volyntsev <xeioex@nginx.com>2017-11-17 18:55:07 +0300
committerDmitry Volyntsev <xeioex@nginx.com>2017-11-17 18:55:07 +0300
commit575be638c4beff4cae3dec74a6c4ae0692bde18b (patch)
treecf5024f465d05935c806f4ad15f86a0adb4b5611 /nginx/ngx_http_js_module.c
parent60a43c5e5d1cc279fc5871aeb56c4338da50c309 (diff)
downloadnjs-575be638c4beff4cae3dec74a6c4ae0692bde18b.tar.gz
njs-575be638c4beff4cae3dec74a6c4ae0692bde18b.zip
Fixed exception handling.
njs_vm_exception() is removed and combined with njs_vm_retval(). vm->exception is removed either, exceptions are now stored in vm->retval. It simplifies the client logic, because previously njs_vm_exception() had to be called if njs_vm_retval() fails. Additonally, stack traces are now appended to the retval if an exception happens.
Diffstat (limited to 'nginx/ngx_http_js_module.c')
-rw-r--r--nginx/ngx_http_js_module.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/nginx/ngx_http_js_module.c b/nginx/ngx_http_js_module.c
index e589f11a..e03c40ae 100644
--- a/nginx/ngx_http_js_module.c
+++ b/nginx/ngx_http_js_module.c
@@ -445,7 +445,7 @@ ngx_http_js_handler(ngx_http_request_t *r)
}
if (njs_vm_call(ctx->vm, func, ctx->args, 2) != NJS_OK) {
- njs_vm_exception(ctx->vm, &exception);
+ njs_vm_retval(ctx->vm, &exception);
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
"js exception: %*s", exception.length, exception.start);
@@ -496,7 +496,7 @@ ngx_http_js_variable(ngx_http_request_t *r, ngx_http_variable_value_t *v,
}
if (njs_vm_call(ctx->vm, func, ctx->args, 2) != NJS_OK) {
- njs_vm_exception(ctx->vm, &exception);
+ njs_vm_retval(ctx->vm, &exception);
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
"js exception: %*s", exception.length, exception.start);
@@ -1333,7 +1333,7 @@ ngx_http_js_include(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
rc = njs_vm_compile(jlcf->vm, &start, end);
if (rc != NJS_OK) {
- njs_vm_exception(jlcf->vm, &text);
+ njs_vm_retval(jlcf->vm, &text);
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
"%*s, included",