diff options
Diffstat (limited to 'src/njs_error.c')
-rw-r--r-- | src/njs_error.c | 47 |
1 files changed, 26 insertions, 21 deletions
diff --git a/src/njs_error.c b/src/njs_error.c index 6e12aa61..d19e0e22 100644 --- a/src/njs_error.c +++ b/src/njs_error.c @@ -212,12 +212,6 @@ njs_error_alloc(njs_vm_t *vm, njs_object_t *proto, const njs_value_t *name, lhq.proto = &njs_object_hash_proto; if (name != NULL) { - prop = njs_object_prop_alloc(vm, name, 1); - if (njs_slow_path(prop == NULL)) { - goto memory_error; - } - - lhq.value = prop; lhq.key_hash = NJS_ATOM_STRING_name; ret = njs_flathsh_unique_insert(&error->hash, &lhq); @@ -225,17 +219,18 @@ njs_error_alloc(njs_vm_t *vm, njs_object_t *proto, const njs_value_t *name, njs_internal_error(vm, "lvlhsh insert failed"); return NULL; } - } - if (message!= NULL) { - prop = njs_object_prop_alloc(vm, message, 1); - if (njs_slow_path(prop == NULL)) { - goto memory_error; - } + prop = lhq.value; - prop->enumerable = 0; + prop->type = NJS_PROPERTY; + prop->enumerable = 1; + prop->configurable = 1; + prop->writable = 1; + + prop->u.value = *name; + } - lhq.value = prop; + if (message!= NULL) { lhq.key_hash = NJS_ATOM_STRING_message; ret = njs_flathsh_unique_insert(&error->hash, &lhq); @@ -243,17 +238,18 @@ njs_error_alloc(njs_vm_t *vm, njs_object_t *proto, const njs_value_t *name, njs_internal_error(vm, "lvlhsh insert failed"); return NULL; } - } - if (errors != NULL) { - prop = njs_object_prop_alloc(vm, errors, 1); - if (njs_slow_path(prop == NULL)) { - goto memory_error; - } + prop = lhq.value; + prop->type = NJS_PROPERTY; prop->enumerable = 0; + prop->configurable = 1; + prop->writable = 1; - lhq.value = prop; + prop->u.value = *message; + } + + if (errors != NULL) { lhq.key_hash = NJS_ATOM_STRING_errors; ret = njs_flathsh_unique_insert(&error->hash, &lhq); @@ -261,6 +257,15 @@ njs_error_alloc(njs_vm_t *vm, njs_object_t *proto, const njs_value_t *name, njs_internal_error(vm, "lvlhsh insert failed"); return NULL; } + + prop = lhq.value; + + prop->type = NJS_PROPERTY; + prop->enumerable = 0; + prop->configurable = 1; + prop->writable = 1; + + prop->u.value = *errors; } return error; |