[njs] Renaming ngx_js_retval() to ngx_js_exception().
Dmitry Volyntsev
xeioex at nginx.com
Tue Nov 21 16:58:03 UTC 2023
details: https://hg.nginx.org/njs/rev/896e7e271382
branches:
changeset: 2237:896e7e271382
user: Dmitry Volyntsev <xeioex at nginx.com>
date: Tue Nov 21 08:57:09 2023 -0800
description:
Renaming ngx_js_retval() to ngx_js_exception().
After previous commit ngx_js_retval() is only used for getting the
exception value and should be renamed to better reflect the purpose.
diffstat:
nginx/ngx_http_js_module.c | 4 ++--
nginx/ngx_js.c | 14 ++++----------
nginx/ngx_js.h | 3 +--
nginx/ngx_stream_js_module.c | 8 ++++----
4 files changed, 11 insertions(+), 18 deletions(-)
diffs (115 lines):
diff -r 1d13f6e877ad -r 896e7e271382 nginx/ngx_http_js_module.c
--- a/nginx/ngx_http_js_module.c Tue Nov 21 08:57:03 2023 -0800
+++ b/nginx/ngx_http_js_module.c Tue Nov 21 08:57:09 2023 -0800
@@ -1401,7 +1401,7 @@ ngx_http_js_init_vm(ngx_http_request_t *
}
if (njs_vm_start(ctx->vm, njs_value_arg(&retval)) == NJS_ERROR) {
- ngx_js_retval(ctx->vm, NULL, &exception);
+ ngx_js_exception(ctx->vm, &exception);
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
"js exception: %V", &exception);
@@ -4526,7 +4526,7 @@ ngx_http_js_handle_vm_event(ngx_http_req
(ngx_int_t) rc, vm_event);
if (rc == NJS_ERROR) {
- ngx_js_retval(ctx->vm, NULL, &exception);
+ ngx_js_exception(ctx->vm, &exception);
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
"js exception: %V", &exception);
diff -r 1d13f6e877ad -r 896e7e271382 nginx/ngx_js.c
--- a/nginx/ngx_js.c Tue Nov 21 08:57:03 2023 -0800
+++ b/nginx/ngx_js.c Tue Nov 21 08:57:09 2023 -0800
@@ -359,7 +359,7 @@ ngx_js_invoke(njs_vm_t *vm, ngx_str_t *f
ret = njs_vm_invoke(vm, func, njs_value_arg(args), nargs,
njs_value_arg(retval));
if (ret == NJS_ERROR) {
- ngx_js_retval(vm, NULL, &exception);
+ ngx_js_exception(vm, &exception);
ngx_log_error(NGX_LOG_ERR, log, 0,
"js exception: %V", &exception);
@@ -369,7 +369,7 @@ ngx_js_invoke(njs_vm_t *vm, ngx_str_t *f
ret = njs_vm_run(vm);
if (ret == NJS_ERROR) {
- ngx_js_retval(vm, NULL, &exception);
+ ngx_js_exception(vm, &exception);
ngx_log_error(NGX_LOG_ERR, log, 0,
"js exception: %V", &exception);
@@ -382,18 +382,12 @@ ngx_js_invoke(njs_vm_t *vm, ngx_str_t *f
ngx_int_t
-ngx_js_retval(njs_vm_t *vm, njs_opaque_value_t *retval, ngx_str_t *s)
+ngx_js_exception(njs_vm_t *vm, ngx_str_t *s)
{
njs_int_t ret;
njs_str_t str;
- if (retval != NULL && njs_value_is_valid(njs_value_arg(retval))) {
- ret = njs_vm_value_string(vm, &str, njs_value_arg(retval));
-
- } else {
- ret = njs_vm_exception_string(vm, &str);
- }
-
+ ret = njs_vm_exception_string(vm, &str);
if (ret != NJS_OK) {
return NGX_ERROR;
}
diff -r 1d13f6e877ad -r 896e7e271382 nginx/ngx_js.h
--- a/nginx/ngx_js.h Tue Nov 21 08:57:03 2023 -0800
+++ b/nginx/ngx_js.h Tue Nov 21 08:57:09 2023 -0800
@@ -133,8 +133,7 @@ ngx_int_t ngx_js_call(njs_vm_t *vm, ngx_
njs_opaque_value_t *args, njs_uint_t nargs);
ngx_int_t ngx_js_invoke(njs_vm_t *vm, ngx_str_t *fname, ngx_log_t *log,
njs_opaque_value_t *args, njs_uint_t nargs, njs_opaque_value_t *retval);
-ngx_int_t ngx_js_retval(njs_vm_t *vm, njs_opaque_value_t *retval,
- ngx_str_t *s);
+ngx_int_t ngx_js_exception(njs_vm_t *vm, ngx_str_t *s);
njs_int_t ngx_js_ext_log(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,
njs_index_t level, njs_value_t *retval);
diff -r 1d13f6e877ad -r 896e7e271382 nginx/ngx_stream_js_module.c
--- a/nginx/ngx_stream_js_module.c Tue Nov 21 08:57:03 2023 -0800
+++ b/nginx/ngx_stream_js_module.c Tue Nov 21 08:57:09 2023 -0800
@@ -754,7 +754,7 @@ ngx_stream_js_phase_handler(ngx_stream_s
ret = ngx_stream_js_run_event(s, ctx, &ctx->events[NGX_JS_EVENT_UPLOAD], 0);
if (ret != NJS_OK) {
- ngx_js_retval(ctx->vm, NULL, &exception);
+ ngx_js_exception(ctx->vm, &exception);
ngx_log_error(NGX_LOG_ERR, c->log, 0, "js exception: %V",
&exception);
@@ -841,7 +841,7 @@ ngx_stream_js_body_filter(ngx_stream_ses
if (event->ev != NULL) {
ret = ngx_stream_js_run_event(s, ctx, event, from_upstream);
if (ret != NJS_OK) {
- ngx_js_retval(ctx->vm, NULL, &exception);
+ ngx_js_exception(ctx->vm, &exception);
ngx_log_error(NGX_LOG_ERR, c->log, 0, "js exception: %V",
&exception);
@@ -1063,7 +1063,7 @@ ngx_stream_js_init_vm(ngx_stream_session
}
if (njs_vm_start(ctx->vm, njs_value_arg(&retval)) == NJS_ERROR) {
- ngx_js_retval(ctx->vm, NULL, &exception);
+ ngx_js_exception(ctx->vm, &exception);
ngx_log_error(NGX_LOG_ERR, s->connection->log, 0,
"js exception: %V", &exception);
@@ -1812,7 +1812,7 @@ ngx_stream_js_handle_event(ngx_stream_se
(ngx_int_t) rc, vm_event);
if (rc == NJS_ERROR) {
- ngx_js_retval(ctx->vm, NULL, &exception);
+ ngx_js_exception(ctx->vm, &exception);
ngx_log_error(NGX_LOG_ERR, s->connection->log, 0,
"js exception: %V", &exception);
More information about the nginx-devel
mailing list