[njs] Added njs_is_memory_error() function.
Alexander Borisov
alexander.borisov at nginx.com
Tue Dec 3 15:15:52 UTC 2019
details: https://hg.nginx.org/njs/rev/ef64784b77f6
branches:
changeset: 1277:ef64784b77f6
user: Alexander Borisov <alexander.borisov at nginx.com>
date: Tue Dec 03 18:02:40 2019 +0300
description:
Added njs_is_memory_error() function.
diffstat:
src/njs_error.h | 14 ++++++++++++++
src/njs_vm.c | 7 +------
2 files changed, 15 insertions(+), 6 deletions(-)
diffs (39 lines):
diff -r 6e84ff419b88 -r ef64784b77f6 src/njs_error.h
--- a/src/njs_error.h Tue Dec 03 17:58:30 2019 +0300
+++ b/src/njs_error.h Tue Dec 03 18:02:40 2019 +0300
@@ -59,4 +59,18 @@ extern const njs_object_type_init_t njs
extern const njs_object_type_init_t njs_memory_error_type_init;
+njs_inline njs_int_t
+njs_is_memory_error(njs_vm_t *vm, njs_value_t *value)
+{
+ if (njs_is_error(value)
+ && njs_has_prototype(vm, value, NJS_OBJ_TYPE_INTERNAL_ERROR)
+ && !njs_object(value)->extensible)
+ {
+ return 1;
+ }
+
+ return 0;
+}
+
+
#endif /* _NJS_BOOLEAN_H_INCLUDED_ */
diff -r 6e84ff419b88 -r ef64784b77f6 src/njs_vm.c
--- a/src/njs_vm.c Tue Dec 03 17:58:30 2019 +0300
+++ b/src/njs_vm.c Tue Dec 03 18:02:40 2019 +0300
@@ -852,12 +852,7 @@ njs_vm_value_to_string(njs_vm_t *vm, njs
}
if (njs_is_error(src)) {
-
- /* MemoryError is a nonextensible internal error. */
-
- if (njs_has_prototype(vm, src, NJS_OBJ_TYPE_INTERNAL_ERROR)
- && !njs_object(src)->extensible)
- {
+ if (njs_is_memory_error(vm, src)) {
njs_string_get(&njs_string_memory_error, dst);
return NJS_OK;
}
More information about the nginx-devel
mailing list