Welcome! Log In Create A New Profile

Advanced

[njs] Interactive shell: improved error handling.

Dmitry Volyntsev
July 12, 2018 08:26AM
details: http://hg.nginx.org/njs/rev/0c131f169fe6
branches:
changeset: 554:0c131f169fe6
user: Dmitry Volyntsev <xeioex@nginx.com>
date: Thu Jul 12 15:24:18 2018 +0300
description:
Interactive shell: improved error handling.

Previously, compilation errors were not reported in file mode.

diffstat:

njs/njs_shell.c | 15 ++++-----------
1 files changed, 4 insertions(+), 11 deletions(-)

diffs (52 lines):

diff -r c1f9fe4022bc -r 0c131f169fe6 njs/njs_shell.c
--- a/njs/njs_shell.c Tue Jul 03 15:48:04 2018 +0300
+++ b/njs/njs_shell.c Thu Jul 12 15:24:18 2018 +0300
@@ -229,7 +229,6 @@ static nxt_int_t
njs_interactive_shell(njs_opts_t *opts, njs_vm_opt_t *vm_options)
{
njs_vm_t *vm;
- nxt_int_t ret;
nxt_str_t line, out;

vm = njs_vm_create(vm_options);
@@ -266,11 +265,7 @@ njs_interactive_shell(njs_opts_t *opts,

add_history((char *) line.start);

- ret = njs_process_script(vm, opts, &line, &out);
- if (ret != NXT_OK) {
- printf("shell: failed to get retval from VM\n");
- continue;
- }
+ njs_process_script(vm, opts, &line, &out);

printf("%.*s\n", (int) out.length, out.start);

@@ -385,7 +380,7 @@ njs_process_file(njs_opts_t *opts, njs_v

ret = njs_process_script(vm, opts, &script, &out);
if (ret != NXT_OK) {
- fprintf(stderr, "failed to get retval from VM\n");
+ fprintf(stderr, "%.*s\n", (int) out.length, out.start);
ret = NXT_ERROR;
goto done;
}
@@ -426,16 +421,14 @@ njs_process_script(njs_vm_t *vm, njs_opt
}

ret = njs_vm_run(vm);
- if (ret == NXT_AGAIN) {
- return ret;
- }
}

if (njs_vm_retval_to_ext_string(vm, out) != NXT_OK) {
+ *out = nxt_string_value("failed to get retval from VM");
return NXT_ERROR;
}

- return NXT_OK;
+ return ret;
}


_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[njs] Interactive shell: improved error handling.

Dmitry Volyntsev 122 July 12, 2018 08:26AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 72
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 254 on July 05, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready