]> git.kaiwu.me - njs.git/commitdiff
Improved wording for InternalError messages.
authorDmitry Volyntsev <xeioex@nginx.com>
Fri, 31 Aug 2018 13:55:35 +0000 (16:55 +0300)
committerDmitry Volyntsev <xeioex@nginx.com>
Fri, 31 Aug 2018 13:55:35 +0000 (16:55 +0300)
njs/njs_error.c
njs/njs_extern.c
njs/njs_fs.c
njs/njs_generator.c
njs/njs_json.c
njs/njs_object.c
njs/njs_regexp.c
njs/njs_variable.c

index 2cdc48e11f47223dc5eac7bc8a6569df801fa436..7b5e6c174058ac74e6cc6f480956355c29b46c40 100644 (file)
@@ -87,7 +87,7 @@ njs_error_alloc(njs_vm_t *vm, njs_value_type_t type, const njs_value_t *name,
 
         ret = nxt_lvlhsh_insert(&error->hash, &lhq);
         if (nxt_slow_path(ret != NXT_OK)) {
-            njs_internal_error(vm, NULL);
+            njs_internal_error(vm, "lvlhsh insert failed");
             return NULL;
         }
     }
@@ -108,7 +108,7 @@ njs_error_alloc(njs_vm_t *vm, njs_value_type_t type, const njs_value_t *name,
 
         ret = nxt_lvlhsh_insert(&error->hash, &lhq);
         if (nxt_slow_path(ret != NXT_OK)) {
-            njs_internal_error(vm, NULL);
+            njs_internal_error(vm, "lvlhsh insert failed");
             return NULL;
         }
     }
index 07dcccdb6fe073cda07f2e122a6de12dae61266b..c87455bdbd96377b119996a688eb9a617d6fd255 100644 (file)
@@ -144,7 +144,7 @@ njs_vm_external_add(njs_vm_t *vm, nxt_lvlhsh_t *hash, njs_external_t *external,
 
             ret = nxt_lvlhsh_insert(hash, &lhq);
             if (nxt_slow_path(ret != NXT_OK)) {
-                njs_internal_error(vm, NULL);
+                njs_internal_error(vm, "lvlhsh insert failed");
                 return NULL;
             }
         }
@@ -229,7 +229,7 @@ njs_vm_external_bind(njs_vm_t *vm, const nxt_str_t *var_name,
 
     ret = nxt_lvlhsh_insert(&vm->externals_hash, &lhq);
     if (nxt_slow_path(ret != NXT_OK)) {
-        njs_internal_error(vm, NULL);
+        njs_internal_error(vm, "lvlhsh insert failed");
         return ret;
     }
 
index 112f3db5e7a8f4e54bf31c5761731241242c55a1..6e6c61ccc13cd491620cf4ba9b690e6f81f76959 100644 (file)
@@ -923,7 +923,7 @@ static njs_ret_t njs_fs_error(njs_vm_t *vm, const char *syscall,
 
         ret = nxt_lvlhsh_insert(&error->hash, &lhq);
         if (nxt_slow_path(ret != NXT_OK)) {
-            njs_internal_error(vm, NULL);
+            njs_internal_error(vm, "lvlhsh insert failed");
             return NJS_ERROR;
         }
     }
@@ -942,7 +942,7 @@ static njs_ret_t njs_fs_error(njs_vm_t *vm, const char *syscall,
 
         ret = nxt_lvlhsh_insert(&error->hash, &lhq);
         if (nxt_slow_path(ret != NXT_OK)) {
-            njs_internal_error(vm, NULL);
+            njs_internal_error(vm, "lvlhsh insert failed");
             return NJS_ERROR;
         }
     }
@@ -967,7 +967,7 @@ static njs_ret_t njs_fs_error(njs_vm_t *vm, const char *syscall,
 
         ret = nxt_lvlhsh_insert(&error->hash, &lhq);
         if (nxt_slow_path(ret != NXT_OK)) {
-            njs_internal_error(vm, NULL);
+            njs_internal_error(vm, "lvlhsh insert failed");
             return NJS_ERROR;
         }
     }
index c35289fe67478d888ca336ff92865af2eb80cb86..d33e987b1c1ea4241d138cb2f4871a57a84bb1af 100644 (file)
@@ -2066,7 +2066,8 @@ njs_generate_scope(njs_vm_t *vm, njs_parser_t *parser, njs_parser_node_t *node)
                          parser->code_size, code_size);
 
     if (nxt_slow_path(parser->code_size < code_size)) {
-        njs_internal_error(vm, NULL);
+        njs_internal_error(vm, "code size mismatch actual %uz < expected %uz",
+                           parser->code_size, code_size);
         return NXT_ERROR;
     }
 
index 3c33da87e06c6bce14f600d397104ee6765f478f..f2f6fc4bcf520a6b1f9429bad6bc332158e8bd4a 100644 (file)
@@ -474,7 +474,7 @@ njs_json_parse_object(njs_json_parse_ctx_t *ctx, njs_value_t *value,
 
         ret = nxt_lvlhsh_insert(&object->hash, &lhq);
         if (nxt_slow_path(ret != NXT_OK)) {
-            njs_internal_error(ctx->vm, NULL);
+            njs_internal_error(ctx->vm, "lvlhsh insert/replace failed");
             return NULL;
         }
 
@@ -568,7 +568,6 @@ njs_json_parse_array(njs_json_parse_ctx_t *ctx, njs_value_t *value,
 
         ret = njs_array_add(ctx->vm, array, element);
         if (nxt_slow_path(ret != NXT_OK)) {
-            njs_internal_error(ctx->vm, NULL);
             return NULL;
         }
 
@@ -982,7 +981,7 @@ njs_json_parse_continuation(njs_vm_t *vm, njs_value_t *args, nxt_uint_t nargs,
             }
 
             if (nxt_slow_path(ret != NXT_OK)) {
-                njs_internal_error(vm, NULL);
+                njs_internal_error(vm, "lvlhsh insert/replace failed");
                 return NXT_ERROR;
             }
 
@@ -1020,7 +1019,8 @@ njs_json_parse_continuation(njs_vm_t *vm, njs_value_t *args, nxt_uint_t nargs,
             break;
 
         default:
-            njs_internal_error(vm, NULL);
+            njs_internal_error(vm, "Unexpected state %d in JSON.parse()",
+                               state->type);
             return NXT_ERROR;
         }
     }
@@ -1062,7 +1062,8 @@ njs_json_parse_continuation_apply(njs_vm_t *vm, njs_json_parse_t *parse)
         break;
 
     default:
-        njs_internal_error(vm, NULL);
+        njs_internal_error(vm, "Unexpected state %d in JSON.parse() apply",
+                           state->type);
         return NXT_ERROR;
     }
 
@@ -1489,7 +1490,8 @@ njs_json_stringify_to_json(njs_vm_t *vm, njs_json_stringify_t* stringify,
         break;
 
     default:
-        njs_internal_error(vm, NULL);
+        njs_internal_error(vm, "Unexpected state %d in JSON.stringify() apply",
+                           state->type);
         return NXT_ERROR;
     }
 
@@ -1533,7 +1535,8 @@ njs_json_stringify_replacer(njs_vm_t *vm, njs_json_stringify_t* stringify,
         break;
 
     default:
-        njs_internal_error(vm, NULL);
+        njs_internal_error(vm, "Unexpected state %d in "
+                           "JSON.stringify() replacer", state->type);
         return NXT_ERROR;
     }
 
index 2c108f252abbc654271abd8a1ef43e000babf7b0..45118f0184abfe0c9308b6115a65afe9013e874b 100644 (file)
@@ -117,7 +117,7 @@ njs_object_hash_create(njs_vm_t *vm, nxt_lvlhsh_t *hash,
 
         ret = nxt_lvlhsh_insert(hash, &lhq);
         if (nxt_slow_path(ret != NXT_OK)) {
-            njs_internal_error(vm, NULL);
+            njs_internal_error(vm, "lvlhsh insert failed");
             return NXT_ERROR;
         }
 
@@ -916,7 +916,7 @@ njs_define_property(njs_vm_t *vm, njs_object_t *object, const njs_value_t *name,
 
         ret = nxt_lvlhsh_insert(&object->hash, &lhq);
         if (nxt_slow_path(ret != NXT_OK)) {
-            njs_internal_error(vm, NULL);
+            njs_internal_error(vm, "lvlhsh insert failed");
             return NXT_ERROR;
         }
 
@@ -1077,7 +1077,7 @@ njs_object_get_own_property_descriptor(njs_vm_t *vm, njs_value_t *args,
 
     ret = nxt_lvlhsh_insert(&descriptor->hash, &lhq);
     if (nxt_slow_path(ret != NXT_OK)) {
-        njs_internal_error(vm, NULL);
+        njs_internal_error(vm, "lvlhsh insert failed");
         return NXT_ERROR;
     }
 
@@ -1095,7 +1095,7 @@ njs_object_get_own_property_descriptor(njs_vm_t *vm, njs_value_t *args,
 
     ret = nxt_lvlhsh_insert(&descriptor->hash, &lhq);
     if (nxt_slow_path(ret != NXT_OK)) {
-        njs_internal_error(vm, NULL);
+        njs_internal_error(vm, "lvlhsh insert failed");
         return NXT_ERROR;
     }
 
@@ -1113,7 +1113,7 @@ njs_object_get_own_property_descriptor(njs_vm_t *vm, njs_value_t *args,
 
     ret = nxt_lvlhsh_insert(&descriptor->hash, &lhq);
     if (nxt_slow_path(ret != NXT_OK)) {
-        njs_internal_error(vm, NULL);
+        njs_internal_error(vm, "lvlhsh insert failed");
         return NXT_ERROR;
     }
 
@@ -1131,7 +1131,7 @@ njs_object_get_own_property_descriptor(njs_vm_t *vm, njs_value_t *args,
 
     ret = nxt_lvlhsh_insert(&descriptor->hash, &lhq);
     if (nxt_slow_path(ret != NXT_OK)) {
-        njs_internal_error(vm, NULL);
+        njs_internal_error(vm, "lvlhsh insert failed");
         return NXT_ERROR;
     }
 
@@ -1488,7 +1488,7 @@ njs_property_prototype_create(njs_vm_t *vm, nxt_lvlhsh_t *hash,
         return &prop->value;
     }
 
-    njs_internal_error(vm, NULL);
+    njs_internal_error(vm, "lvlhsh insert failed");
 
     return NULL;
 }
@@ -1730,7 +1730,7 @@ njs_property_constructor_create(njs_vm_t *vm, nxt_lvlhsh_t *hash,
         return &prop->value;
     }
 
-    njs_internal_error(vm, NULL);
+    njs_internal_error(vm, "lvlhsh insert failed");
 
     return NULL;
 }
index cf8068b5a3bd452570983c5f8a56242ea7956839..8ac7c42e156de8274b0f0e0324b1036431ed6284 100644 (file)
@@ -327,7 +327,7 @@ njs_regexp_pattern_create(njs_vm_t *vm, u_char *start, size_t length,
     if (nxt_fast_path(ret >= 0)) {
 
         if (nxt_slow_path((u_int) ret != pattern->ncaptures)) {
-            njs_internal_error(vm, NULL);
+            njs_internal_error(vm, "regexp pattern compile failed");
             nxt_mem_cache_free(vm->mem_cache_pool, pattern);
             return NULL;
         }
@@ -755,7 +755,7 @@ njs_regexp_exec_result(njs_vm_t *vm, njs_regexp_t *regexp, njs_utf8_t utf8,
 
     ret = nxt_lvlhsh_insert(&array->object.hash, &lhq);
     if (nxt_slow_path(ret != NXT_OK)) {
-        njs_internal_error(vm, NULL);
+        njs_internal_error(vm, "lvlhsh insert failed");
         goto fail;
     }
 
index 569e8215ba84a05f09b212047355aad28bbb940c..33ee2c7470d6ea0b63cbfb72a48a4f45c934acab 100644 (file)
@@ -83,7 +83,7 @@ njs_builtin_add(njs_vm_t *vm, njs_parser_t *parser)
     ret = nxt_lvlhsh_insert(&scope->variables, &lhq);
 
     if (nxt_fast_path(ret == NXT_OK)) {
-        njs_internal_error(vm, NULL);
+        njs_internal_error(vm, "lvlhsh insert failed");
         return var;
     }