[njs] Improved wording for primitive type conversion exception.

Dmitry Volyntsev xeioex at nginx.com
Mon Aug 20 15:58:11 UTC 2018


details:   http://hg.nginx.org/njs/rev/aa0459712007
branches:  
changeset: 583:aa0459712007
user:      Dmitry Volyntsev <xeioex at nginx.com>
date:      Mon Aug 20 18:58:03 2018 +0300
description:
Improved wording for primitive type conversion exception.

diffstat:

 njs/njs_vm.c                    |  3 ++-
 njs/test/njs_interactive_test.c |  2 +-
 njs/test/njs_unit_test.c        |  8 ++++----
 3 files changed, 7 insertions(+), 6 deletions(-)

diffs (59 lines):

diff -r d2cbea77122c -r aa0459712007 njs/njs_vm.c
--- a/njs/njs_vm.c	Thu Aug 02 19:39:55 2018 +0300
+++ b/njs/njs_vm.c	Mon Aug 20 18:58:03 2018 +0300
@@ -3204,7 +3204,8 @@ njs_primitive_value(njs_vm_t *vm, njs_va
                 }
 
                 if (ret == NXT_ERROR) {
-                    njs_type_error(vm, "cannot evaluate an object's value");
+                    njs_type_error(vm,
+                                   "Cannot convert object to primitive value");
                 }
 
                 return ret;
diff -r d2cbea77122c -r aa0459712007 njs/test/njs_interactive_test.c
--- a/njs/test/njs_interactive_test.c	Thu Aug 02 19:39:55 2018 +0300
+++ b/njs/test/njs_interactive_test.c	Mon Aug 20 18:58:03 2018 +0300
@@ -215,7 +215,7 @@ static njs_interactive_test_t  njs_test[
 
     { nxt_string("var o = { toString: function() { return [1] } }" ENTER
                  "o" ENTER),
-      nxt_string("TypeError: cannot evaluate an object's value\n"
+      nxt_string("TypeError: Cannot convert object to primitive value\n"
                  "    at main (native)\n") },
 
 };
diff -r d2cbea77122c -r aa0459712007 njs/test/njs_unit_test.c
--- a/njs/test/njs_unit_test.c	Thu Aug 02 19:39:55 2018 +0300
+++ b/njs/test/njs_unit_test.c	Mon Aug 20 18:58:03 2018 +0300
@@ -4322,7 +4322,7 @@ static njs_unit_test_t  njs_test[] =
 
     { nxt_string("var r = { toString: function() { return /45/ } };"
                  "'123456'.search(r)"),
-      nxt_string("TypeError: cannot evaluate an object's value") },
+      nxt_string("TypeError: Cannot convert object to primitive value") },
 
     { nxt_string("var r = { toString: function() { return /34/ },"
                  "          valueOf:  function() { return 45 } };"
@@ -4456,7 +4456,7 @@ static njs_unit_test_t  njs_test[] =
 
     { nxt_string("var r = { toString: function() { return /45/ } };"
                  "'123456'.match(r)"),
-      nxt_string("TypeError: cannot evaluate an object's value") },
+      nxt_string("TypeError: Cannot convert object to primitive value") },
 
     { nxt_string("var r = { toString: function() { return /34/ },"
                  "          valueOf:  function() { return 45 } };"
@@ -5927,10 +5927,10 @@ static njs_unit_test_t  njs_test[] =
       nxt_string("o:OK") },
 
     { nxt_string("var o = { toString: function() { return [1] } }; o"),
-      nxt_string("TypeError: cannot evaluate an object's value") },
+      nxt_string("TypeError: Cannot convert object to primitive value") },
 
     { nxt_string("var o = { toString: function() { return [1] } }; 'o:' + o"),
-      nxt_string("TypeError: cannot evaluate an object's value") },
+      nxt_string("TypeError: Cannot convert object to primitive value") },
 
     { nxt_string("var a = { valueOf: function() { return '3' } };"
                  "var b = { toString: function() { return 10 - a + 'OK' } };"


More information about the nginx-devel mailing list