size = (uint32_t) num;
if ((double) size != num) {
- njs_exception_range_error(vm, NULL, NULL);
+ njs_range_error(vm, NULL, NULL);
return NXT_ERROR;
}
n = njs_array_iterator_index(array, iter);
if (n == NJS_ARRAY_INVALID_INDEX) {
- njs_exception_type_error(vm, "invalid index", NULL);
+ njs_type_error(vm, "invalid index", NULL);
return NXT_ERROR;
}
return NXT_OK;
}
- njs_exception_type_error(vm, "unexpected iterator arguments", NULL);
+ njs_type_error(vm, "unexpected iterator arguments", NULL);
return NXT_ERROR;
}
n = njs_array_reduce_right_index(array, iter);
if (n == NJS_ARRAY_INVALID_INDEX) {
- njs_exception_type_error(vm, "invalid index", NULL);
+ njs_type_error(vm, "invalid index", NULL);
return NXT_ERROR;
}
value = &value->data.u.object_value->value;
} else {
- njs_exception_type_error(vm, "unexpected value type:%s",
- njs_type_string(value->type));
+ njs_type_error(vm, "unexpected value type:%s",
+ njs_type_string(value->type));
return NXT_ERROR;
}
}
value = &value->data.u.object_value->value;
} else {
- njs_exception_type_error(vm, "unexpected value type:%s",
- njs_type_string(value->type));
+ njs_type_error(vm, "unexpected value type:%s",
+ njs_type_string(value->type));
return NXT_ERROR;
}
}
&njs_eval_error_prototype_init,
&njs_internal_error_prototype_init,
&njs_range_error_prototype_init,
- &njs_ref_error_prototype_init,
+ &njs_reference_error_prototype_init,
&njs_syntax_error_prototype_init,
&njs_type_error_prototype_init,
&njs_uri_error_prototype_init,
&njs_eval_error_constructor_init,
&njs_internal_error_constructor_init,
&njs_range_error_constructor_init,
- &njs_ref_error_constructor_init,
+ &njs_reference_error_constructor_init,
&njs_syntax_error_constructor_init,
&njs_type_error_constructor_init,
&njs_uri_error_constructor_init,
{ NJS_SKIP_ARG, NJS_STRING_ARG } },
{ njs_range_error_constructor,
{ NJS_SKIP_ARG, NJS_STRING_ARG } },
- { njs_ref_error_constructor, { NJS_SKIP_ARG, NJS_STRING_ARG } },
+ { njs_reference_error_constructor, { NJS_SKIP_ARG, NJS_STRING_ARG } },
{ njs_syntax_error_constructor,
{ NJS_SKIP_ARG, NJS_STRING_ARG } },
{ njs_type_error_constructor, { NJS_SKIP_ARG, NJS_STRING_ARG } },
return njs_string_new(vm, &vm->retval, buf, size, size);
}
- njs_exception_range_error(vm, NULL, NULL);
+ njs_range_error(vm, NULL, NULL);
return NXT_ERROR;
}
}
}
- njs_exception_type_error(vm, "'this' argument is not an object", NULL);
+ njs_type_error(vm, "'this' argument is not an object", NULL);
return NXT_ERROR;
}
memory_error:
- njs_exception_memory_error(vm);
+ njs_memory_error(vm);
}
error = njs_error_alloc(vm, type, NULL, value);
if (nxt_slow_path(error == NULL)) {
- njs_exception_memory_error(vm);
+ njs_memory_error(vm);
return NXT_ERROR;
}
njs_ret_t
-njs_ref_error_constructor(njs_vm_t *vm, njs_value_t *args,
+njs_reference_error_constructor(njs_vm_t *vm, njs_value_t *args,
nxt_uint_t nargs, njs_index_t unused)
{
return njs_error_create(vm, args, nargs, NJS_OBJECT_REF_ERROR);
}
-static const njs_object_prop_t njs_ref_error_constructor_properties[] =
+static const njs_object_prop_t njs_reference_error_constructor_properties[] =
{
/* ReferenceError.name == "ReferenceError". */
{
};
-const njs_object_init_t njs_ref_error_constructor_init = {
+const njs_object_init_t njs_reference_error_constructor_init = {
nxt_string("ReferenceError"),
- njs_ref_error_constructor_properties,
- nxt_nitems(njs_ref_error_constructor_properties),
+ njs_reference_error_constructor_properties,
+ nxt_nitems(njs_reference_error_constructor_properties),
};
void
-njs_exception_memory_error(njs_vm_t *vm)
+njs_memory_error(njs_vm_t *vm)
{
njs_set_memory_error(vm, &vm->retval);
}
static const njs_value_t default_name = njs_string("Error");
if (nargs < 1 || !njs_is_object(&args[0])) {
- njs_exception_type_error(vm, "'this' argument is not an object", NULL);
+ njs_type_error(vm, "'this' argument is not an object", NULL);
return NXT_ERROR;
}
return NJS_OK;
}
- njs_exception_memory_error(vm);
+ njs_memory_error(vm);
return NJS_ERROR;
}
};
-static const njs_object_prop_t njs_ref_error_prototype_properties[] =
+static const njs_object_prop_t njs_reference_error_prototype_properties[] =
{
{
.type = NJS_PROPERTY,
};
-const njs_object_init_t njs_ref_error_prototype_init = {
+const njs_object_init_t njs_reference_error_prototype_init = {
nxt_string("ReferenceError"),
- njs_ref_error_prototype_properties,
- nxt_nitems(njs_ref_error_prototype_properties),
+ njs_reference_error_prototype_properties,
+ nxt_nitems(njs_reference_error_prototype_properties),
};
#define _NJS_ERROR_H_INCLUDED_
-#define njs_exception_error(vm, fmt, ...) \
+#define njs_error(vm, fmt, ...) \
njs_exception_error_create(vm, NJS_OBJECT_ERROR, fmt, __VA_ARGS__)
-#define njs_exception_eval_error(vm, fmt, ...) \
+#define njs_eval_error(vm, fmt, ...) \
njs_exception_error_create(vm, NJS_OBJECT_EVAL_ERROR, fmt, __VA_ARGS__)
-#define njs_exception_internal_error(vm, fmt, ...) \
+#define njs_internal_error(vm, fmt, ...) \
njs_exception_error_create(vm, NJS_OBJECT_INTERNAL_ERROR, fmt, __VA_ARGS__)
-#define njs_exception_range_error(vm, fmt, ...) \
+#define njs_range_error(vm, fmt, ...) \
njs_exception_error_create(vm, NJS_OBJECT_RANGE_ERROR, fmt, __VA_ARGS__)
-#define njs_exception_ref_error(vm, fmt, ...) \
+#define njs_reference_error(vm, fmt, ...) \
njs_exception_error_create(vm, NJS_OBJECT_REF_ERROR, fmt, __VA_ARGS__)
-#define njs_exception_syntax_error(vm, fmt, ...) \
+#define njs_syntax_error(vm, fmt, ...) \
njs_exception_error_create(vm, NJS_OBJECT_SYNTAX_ERROR, fmt, __VA_ARGS__)
-#define njs_exception_type_error(vm, fmt, ...) \
+#define njs_type_error(vm, fmt, ...) \
njs_exception_error_create(vm, NJS_OBJECT_TYPE_ERROR, fmt, __VA_ARGS__)
-#define njs_exception_uri_error(vm, fmt, ...) \
+#define njs_uri_error(vm, fmt, ...) \
njs_exception_error_create(vm, NJS_OBJECT_URI_ERROR, fmt, __VA_ARGS__)
void njs_exception_error_create(njs_vm_t *vm, njs_value_type_t type,
const char* fmt, ...);
-void njs_exception_memory_error(njs_vm_t *vm);
+void njs_memory_error(njs_vm_t *vm);
void njs_set_memory_error(njs_vm_t *vm, njs_value_t *value);
njs_object_t *njs_error_alloc(njs_vm_t *vm, njs_value_type_t type,
nxt_uint_t nargs, njs_index_t unused);
njs_ret_t njs_range_error_constructor(njs_vm_t *vm, njs_value_t *args,
nxt_uint_t nargs, njs_index_t unused);
-njs_ret_t njs_ref_error_constructor(njs_vm_t *vm, njs_value_t *args,
+njs_ret_t njs_reference_error_constructor(njs_vm_t *vm, njs_value_t *args,
nxt_uint_t nargs, njs_index_t unused);
njs_ret_t njs_syntax_error_constructor(njs_vm_t *vm, njs_value_t *args,
nxt_uint_t nargs, njs_index_t unused);
extern const njs_object_init_t njs_eval_error_constructor_init;
extern const njs_object_init_t njs_internal_error_constructor_init;
extern const njs_object_init_t njs_range_error_constructor_init;
-extern const njs_object_init_t njs_ref_error_constructor_init;
+extern const njs_object_init_t njs_reference_error_constructor_init;
extern const njs_object_init_t njs_syntax_error_constructor_init;
extern const njs_object_init_t njs_type_error_constructor_init;
extern const njs_object_init_t njs_uri_error_constructor_init;
extern const njs_object_init_t njs_eval_error_prototype_init;
extern const njs_object_init_t njs_internal_error_prototype_init;
extern const njs_object_init_t njs_range_error_prototype_init;
-extern const njs_object_init_t njs_ref_error_prototype_init;
+extern const njs_object_init_t njs_reference_error_prototype_init;
extern const njs_object_init_t njs_syntax_error_prototype_init;
extern const njs_object_init_t njs_type_error_prototype_init;
extern const njs_object_init_t njs_uri_error_prototype_init;
ret = nxt_lvlhsh_insert(&vm->events_hash, &lhq);
if (nxt_slow_path(ret != NXT_OK)) {
- njs_exception_internal_error(vm, "Failed to add event with id: %s",
- njs_string_short_start(&event->id));
+ njs_internal_error(vm, "Failed to add event with id: %s",
+ njs_string_short_start(&event->id));
njs_del_event(vm, event, NJS_EVENT_RELEASE | NJS_EVENT_DELETE);
return NJS_ERROR;
nxt_lvlhsh_query_t lhq;
if (nxt_slow_path(nargs < 3)) {
- njs_exception_type_error(vm, "too few arguments", NULL);
+ njs_type_error(vm, "too few arguments", NULL);
return NJS_ERROR;
}
if (nxt_slow_path(!njs_is_string(&args[1]))) {
- njs_exception_type_error(vm, "path must be a string", NULL);
+ njs_type_error(vm, "path must be a string", NULL);
return NJS_ERROR;
}
}
} else {
- njs_exception_type_error(vm, "Unknown options type "
- "(a string or object required)", NULL);
+ njs_type_error(vm, "Unknown options type "
+ "(a string or object required)", NULL);
return NJS_ERROR;
}
if (nxt_slow_path(nargs < 4 || !njs_is_function(&args[3]))) {
- njs_exception_type_error(vm, "callback must be a function", NULL);
+ njs_type_error(vm, "callback must be a function", NULL);
return NJS_ERROR;
}
} else {
if (nxt_slow_path(!njs_is_function(&args[2]))) {
- njs_exception_type_error(vm, "callback must be a function", NULL);
+ njs_type_error(vm, "callback must be a function", NULL);
return NJS_ERROR;
}
flags = njs_fs_flags(&flag);
if (nxt_slow_path(flags == -1)) {
- njs_exception_type_error(vm, "Unknown file open flags: '%.*s'",
- (int) flag.length, flag.start);
+ njs_type_error(vm, "Unknown file open flags: '%.*s'",
+ (int) flag.length, flag.start);
return NJS_ERROR;
}
if (encoding.length != 0
&& (encoding.length != 4 || memcmp(encoding.start, "utf8", 4) != 0))
{
- njs_exception_type_error(vm, "Unknown encoding: '%.*s'",
- (int) encoding.length, encoding.start);
+ njs_type_error(vm, "Unknown encoding: '%.*s'",
+ (int) encoding.length, encoding.start);
return NJS_ERROR;
}
(void) close(fd);
}
- njs_exception_memory_error(vm);
+ njs_memory_error(vm);
return NJS_ERROR;
}
nxt_lvlhsh_query_t lhq;
if (nxt_slow_path(nargs < 2)) {
- njs_exception_type_error(vm, "too few arguments", NULL);
+ njs_type_error(vm, "too few arguments", NULL);
return NJS_ERROR;
}
if (nxt_slow_path(!njs_is_string(&args[1]))) {
- njs_exception_type_error(vm, "path must be a string", NULL);
+ njs_type_error(vm, "path must be a string", NULL);
return NJS_ERROR;
}
}
} else {
- njs_exception_type_error(vm, "Unknown options type "
- "(a string or object required)", NULL);
+ njs_type_error(vm, "Unknown options type "
+ "(a string or object required)", NULL);
return NJS_ERROR;
}
}
flags = njs_fs_flags(&flag);
if (nxt_slow_path(flags == -1)) {
- njs_exception_type_error(vm, "Unknown file open flags: '%.*s'",
- (int) flag.length, flag.start);
+ njs_type_error(vm, "Unknown file open flags: '%.*s'",
+ (int) flag.length, flag.start);
return NJS_ERROR;
}
if (encoding.length != 0
&& (encoding.length != 4 || memcmp(encoding.start, "utf8", 4) != 0))
{
- njs_exception_type_error(vm, "Unknown encoding: '%.*s'",
- (int) encoding.length, encoding.start);
+ njs_type_error(vm, "Unknown encoding: '%.*s'",
+ (int) encoding.length, encoding.start);
return NJS_ERROR;
}
(void) close(fd);
}
- njs_exception_memory_error(vm);
+ njs_memory_error(vm);
return NJS_ERROR;
}
nxt_lvlhsh_query_t lhq;
if (nxt_slow_path(nargs < 4)) {
- njs_exception_type_error(vm, "too few arguments", NULL);
+ njs_type_error(vm, "too few arguments", NULL);
return NJS_ERROR;
}
if (nxt_slow_path(!njs_is_string(&args[1]))) {
- njs_exception_type_error(vm, "path must be a string", NULL);
+ njs_type_error(vm, "path must be a string", NULL);
return NJS_ERROR;
}
if (nxt_slow_path(!njs_is_string(&args[2]))) {
- njs_exception_type_error(vm, "data must be a string", NULL);
+ njs_type_error(vm, "data must be a string", NULL);
return NJS_ERROR;
}
}
} else {
- njs_exception_type_error(vm, "Unknown options type "
- "(a string or object required)", NULL);
+ njs_type_error(vm, "Unknown options type "
+ "(a string or object required)", NULL);
return NJS_ERROR;
}
if (nxt_slow_path(nargs < 5 || !njs_is_function(&args[4]))) {
- njs_exception_type_error(vm, "callback must be a function", NULL);
+ njs_type_error(vm, "callback must be a function", NULL);
return NJS_ERROR;
}
} else {
if (nxt_slow_path(!njs_is_function(&args[3]))) {
- njs_exception_type_error(vm, "callback must be a function", NULL);
+ njs_type_error(vm, "callback must be a function", NULL);
return NJS_ERROR;
}
if (flag.start != NULL) {
flags = njs_fs_flags(&flag);
if (nxt_slow_path(flags == -1)) {
- njs_exception_type_error(vm, "Unknown file open flags: '%.*s'",
- (int) flag.length, flag.start);
+ njs_type_error(vm, "Unknown file open flags: '%.*s'",
+ (int) flag.length, flag.start);
return NJS_ERROR;
}
if (encoding.length != 0
&& (encoding.length != 4 || memcmp(encoding.start, "utf8", 4) != 0))
{
- njs_exception_type_error(vm, "Unknown encoding: '%.*s'",
- (int) encoding.length, encoding.start);
+ njs_type_error(vm, "Unknown encoding: '%.*s'",
+ (int) encoding.length, encoding.start);
return NJS_ERROR;
}
nxt_lvlhsh_query_t lhq;
if (nxt_slow_path(nargs < 3)) {
- njs_exception_type_error(vm, "too few arguments", NULL);
+ njs_type_error(vm, "too few arguments", NULL);
return NJS_ERROR;
}
if (nxt_slow_path(!njs_is_string(&args[1]))) {
- njs_exception_type_error(vm, "path must be a string", NULL);
+ njs_type_error(vm, "path must be a string", NULL);
return NJS_ERROR;
}
if (nxt_slow_path(!njs_is_string(&args[2]))) {
- njs_exception_type_error(vm, "data must be a string", NULL);
+ njs_type_error(vm, "data must be a string", NULL);
return NJS_ERROR;
}
}
} else {
- njs_exception_type_error(vm, "Unknown options type "
- "(a string or object required)", NULL);
+ njs_type_error(vm, "Unknown options type "
+ "(a string or object required)", NULL);
return NJS_ERROR;
}
}
if (flag.start != NULL) {
flags = njs_fs_flags(&flag);
if (nxt_slow_path(flags == -1)) {
- njs_exception_type_error(vm, "Unknown file open flags: '%.*s'",
- (int) flag.length, flag.start);
+ njs_type_error(vm, "Unknown file open flags: '%.*s'",
+ (int) flag.length, flag.start);
return NJS_ERROR;
}
if (encoding.length != 0
&& (encoding.length != 4 || memcmp(encoding.start, "utf8", 4) != 0))
{
- njs_exception_type_error(vm, "Unknown encoding: '%.*s'",
- (int) encoding.length, encoding.start);
+ njs_type_error(vm, "Unknown encoding: '%.*s'",
+ (int) encoding.length, encoding.start);
return NJS_ERROR;
}
ret = nxt_lvlhsh_insert(&error->hash, &lhq);
if (nxt_slow_path(ret != NXT_OK)) {
- njs_exception_internal_error(vm, NULL, NULL);
+ njs_internal_error(vm, NULL, NULL);
return NJS_ERROR;
}
}
ret = nxt_lvlhsh_insert(&error->hash, &lhq);
if (nxt_slow_path(ret != NXT_OK)) {
- njs_exception_internal_error(vm, NULL, NULL);
+ njs_internal_error(vm, NULL, NULL);
return NJS_ERROR;
}
}
ret = nxt_lvlhsh_insert(&error->hash, &lhq);
if (nxt_slow_path(ret != NXT_OK)) {
- njs_exception_internal_error(vm, NULL, NULL);
+ njs_internal_error(vm, NULL, NULL);
return NJS_ERROR;
}
}
memory_error:
- njs_exception_memory_error(vm);
+ njs_memory_error(vm);
return NJS_ERROR;
}
spare_size = nxt_align_size(spare_size, NJS_FRAME_SPARE_SIZE);
if (vm->stack_size + spare_size > NJS_MAX_STACK_SIZE) {
- njs_exception_range_error(vm, "Maximum call stack size exceeded",
- NULL);
+ njs_range_error(vm, "Maximum call stack size exceeded", NULL);
return NULL;
}
njs_function_t *function;
if (!njs_is_function(&args[0])) {
- njs_exception_type_error(vm, "'this' argument is not a function", NULL);
+ njs_type_error(vm, "'this' argument is not a function", NULL);
return NXT_ERROR;
}
njs_function_t *function;
if (!njs_is_function(&args[0])) {
- njs_exception_type_error(vm, "'this' argument is not a function", NULL);
+ njs_type_error(vm, "'this' argument is not a function", NULL);
return NXT_ERROR;
}
if (nargs > 2) {
if (!njs_is_array(&args[2])) {
- njs_exception_type_error(vm, "second argument is not an array",
- NULL);
+ njs_type_error(vm, "second argument is not an array", NULL);
return NXT_ERROR;
}
njs_function_t *function;
if (!njs_is_function(&args[0])) {
- njs_exception_type_error(vm, "'this' argument is not a function", NULL);
+ njs_type_error(vm, "'this' argument is not a function", NULL);
return NXT_ERROR;
}
njs_eval_function(njs_vm_t *vm, njs_value_t *args, nxt_uint_t nargs,
njs_index_t unused)
{
- njs_exception_internal_error(vm, "Not implemented", NULL);
+ njs_internal_error(vm, "Not implemented", NULL);
return NXT_ERROR;
}
default:
nxt_thread_log_debug("unknown token: %d", node->token);
- njs_exception_syntax_error(vm, "unknown token", NULL);
+ njs_syntax_error(vm, "unknown token", NULL);
return NXT_ERROR;
}
parser->code_size, code_size);
if (nxt_slow_path(parser->code_size < code_size)) {
- njs_exception_internal_error(vm, NULL, NULL);
+ njs_internal_error(vm, NULL, NULL);
return NXT_ERROR;
}
value = nxt_mem_cache_alloc(vm->mem_cache_pool, sizeof(njs_value_t));
if (nxt_slow_path(value == NULL)) {
- njs_exception_memory_error(vm);
+ njs_memory_error(vm);
return NXT_ERROR;
}
memory_error:
- njs_exception_memory_error(vm);
+ njs_memory_error(vm);
return NXT_ERROR;
}
memory_error:
- njs_exception_memory_error(vm);
+ njs_memory_error(vm);
return NXT_ERROR;
}
ret = nxt_lvlhsh_insert(&object->hash, &lhq);
if (nxt_slow_path(ret != NXT_OK)) {
- njs_exception_internal_error(ctx->vm, NULL, NULL);
+ njs_internal_error(ctx->vm, NULL, NULL);
return NULL;
}
memory_error:
- njs_exception_memory_error(ctx->vm);
+ njs_memory_error(ctx->vm);
return NULL;
}
array = njs_array_alloc(ctx->vm, 0, 0);
if (nxt_slow_path(array == NULL)) {
- njs_exception_memory_error(ctx->vm);
+ njs_memory_error(ctx->vm);
return NULL;
}
element = nxt_mem_cache_alloc(ctx->pool, sizeof(njs_value_t));
if (nxt_slow_path(element == NULL)) {
- njs_exception_memory_error(ctx->vm);
+ njs_memory_error(ctx->vm);
return NULL;
}
ret = njs_array_add(ctx->vm, array, element);
if (nxt_slow_path(ret != NXT_OK)) {
- njs_exception_internal_error(ctx->vm, NULL, NULL);
+ njs_internal_error(ctx->vm, NULL, NULL);
return NULL;
}
start = nxt_mem_cache_alloc(ctx->pool, size);
if (nxt_slow_path(start == NULL)) {
- njs_exception_memory_error(ctx->vm);;
+ njs_memory_error(ctx->vm);;
return NULL;
}
ret = njs_string_create(ctx->vm, value, start, size, length);
if (nxt_slow_path(ret != NXT_OK)) {
- njs_exception_memory_error(ctx->vm);
+ njs_memory_error(ctx->vm);
return NULL;
}
}
if (nxt_slow_path(ret != NXT_OK)) {
- njs_exception_internal_error(vm, NULL, NULL);
+ njs_internal_error(vm, NULL, NULL);
return NXT_ERROR;
}
break;
default:
- njs_exception_internal_error(vm, NULL, NULL);
+ njs_internal_error(vm, NULL, NULL);
return NXT_ERROR;
}
}
memory_error:
- njs_exception_memory_error(vm);
+ njs_memory_error(vm);
return NXT_ERROR;
}
break;
default:
- njs_exception_internal_error(vm, NULL, NULL);
+ njs_internal_error(vm, NULL, NULL);
return NXT_ERROR;
}
length = 0;
}
- njs_exception_syntax_error(ctx->vm, "%s at position %zu", msg, length);
+ njs_syntax_error(ctx->vm, "%s at position %zu", msg, length);
}
memory_error:
- njs_exception_memory_error(vm);
+ njs_memory_error(vm);
return NXT_ERROR;
}
break;
default:
- njs_exception_internal_error(vm, NULL, NULL);
+ njs_internal_error(vm, NULL, NULL);
return NXT_ERROR;
}
break;
default:
- njs_exception_internal_error(vm, NULL, NULL);
+ njs_internal_error(vm, NULL, NULL);
return NXT_ERROR;
}
njs_json_state_t *state;
if (stringify->stack.items >= 32) {
- njs_exception_type_error(stringify->vm,
- "Nested too deep or a cyclic structure", NULL);
+ njs_type_error(stringify->vm,
+ "Nested too deep or a cyclic structure", NULL);
return NULL;
}
state = nxt_array_add(&stringify->stack, &njs_array_mem_proto,
vm->mem_cache_pool);
if (nxt_slow_path(state == NULL)) {
- njs_exception_memory_error(vm);
+ njs_memory_error(vm);
return NULL;
}
return njs_json_buf_append(stringify, "null", 4);
default:
- njs_exception_type_error(stringify->vm, "Non-serializable object",
- NULL);
+ njs_type_error(stringify->vm, "Non-serializable object", NULL);
return NXT_DECLINED;
}
}
nxt_lvlhsh_query_t lhq;
if (nargs < 2) {
- njs_exception_type_error(vm, "missing path", NULL);
+ njs_type_error(vm, "missing path", NULL);
return NJS_ERROR;
}
return NXT_OK;
}
- njs_exception_error(vm, "Cannot find module '%.*s'", (int) lhq.key.length,
- lhq.key.start);
+ njs_error(vm, "Cannot find module '%.*s'",
+ (int) lhq.key.length, lhq.key.start);
return NJS_ERROR;
}
value = &value->data.u.object_value->value;
} else {
- njs_exception_type_error(vm, "unexpected value type:%s",
- njs_type_string(value->type));
+ njs_type_error(vm, "unexpected value type:%s",
+ njs_type_string(value->type));
return NXT_ERROR;
}
}
value = &value->data.u.object_value->value;
} else {
- njs_exception_type_error(vm, "unexpected value type:%s",
- njs_type_string(value->type));
+ njs_type_error(vm, "unexpected value type:%s",
+ njs_type_string(value->type));
return NXT_ERROR;
}
}
radix = args[1].data.u.number;
if (radix < 2 || radix > 36 || radix != (int) radix) {
- njs_exception_range_error(vm, NULL, NULL);
+ njs_range_error(vm, NULL, NULL);
return NXT_ERROR;
}
type = njs_object_value_type(value->type);
} else {
- njs_exception_type_error(vm, "unexpected constructor argument:%s",
- njs_type_string(value->type));
+ njs_type_error(vm, "unexpected constructor argument:%s",
+ njs_type_string(value->type));
return NXT_ERROR;
}
}
}
- njs_exception_type_error(vm, "too few arguments", NULL);
+ njs_type_error(vm, "too few arguments", NULL);
return NXT_ERROR;
}
njs_array_t *keys;
if (nargs < 2 || !njs_is_object(&args[1])) {
- njs_exception_type_error(vm, "cannot convert %s argument to object",
- (nargs >= 2) ? njs_type_string(args[1].type)
- : "null");
+ njs_type_error(vm, "cannot convert %s argument to object",
+ (nargs >= 2) ? njs_type_string(args[1].type) : "null");
return NXT_ERROR;
}
keys = njs_object_keys_array(vm, &args[1]);
if (keys == NULL) {
- njs_exception_memory_error(vm);
+ njs_memory_error(vm);
return NXT_ERROR;
}
if (nargs < 4 || !njs_is_object(&args[1]) || !njs_is_object(&args[3])) {
if (nargs < 2 || !njs_is_object(&args[1])) {
type = (nargs > 1) ? njs_type_string(args[1].type) : "null";
- njs_exception_type_error(vm, "cannot convert %s argument to object",
- type);
+ njs_type_error(vm, "cannot convert %s argument to object", type);
} else {
- njs_exception_type_error(vm, "descriptor is not an object", NULL);
+ njs_type_error(vm, "descriptor is not an object", NULL);
}
return NXT_ERROR;
}
if (!args[1].data.u.object->extensible) {
- njs_exception_type_error(vm, "object is not extensible", NULL);
+ njs_type_error(vm, "object is not extensible", NULL);
return NXT_ERROR;
}
if (nargs < 3 || !njs_is_object(&args[1]) || !njs_is_object(&args[2])) {
if (nargs < 2 || !njs_is_object(&args[1])) {
type = (nargs > 1) ? njs_type_string(args[1].type) : "null";
- njs_exception_type_error(vm, "cannot convert %s argument to object",
- type);
+ njs_type_error(vm, "cannot convert %s argument to object", type);
} else {
- njs_exception_type_error(vm, "descriptor is not an object", NULL);
+ njs_type_error(vm, "descriptor is not an object", NULL);
}
return NXT_ERROR;
}
if (!args[1].data.u.object->extensible) {
- njs_exception_type_error(vm, "object is not extensible", NULL);
+ njs_type_error(vm, "object is not extensible", NULL);
return NXT_ERROR;
}
if (nargs < 3 || !njs_is_object(&args[1])) {
type = (nargs > 1) ? njs_type_string(args[1].type) : "null";
- njs_exception_type_error(vm, "cannot convert %s argument to object",
- type);
+ njs_type_error(vm, "cannot convert %s argument to object", type);
return NXT_ERROR;
}
return NXT_OK;
}
- njs_exception_type_error(vm, "cannot convert %s argument to object",
- (nargs > 1) ? njs_type_string(args[1].type)
- : "null");
+ njs_type_error(vm, "cannot convert %s argument to object",
+ (nargs > 1) ? njs_type_string(args[1].type) : "null");
return NXT_ERROR;
}
}
/* Memory allocation or NXT_DECLINED error. */
- njs_exception_internal_error(vm, NULL, NULL);
+ njs_internal_error(vm, NULL, NULL);
return NULL;
}
}
/* Memory allocation or NXT_DECLINED error. */
- njs_exception_internal_error(vm, NULL, NULL);
+ njs_internal_error(vm, NULL, NULL);
return NULL;
}
}
if (try->right == NULL) {
- njs_parser_syntax_error(vm, parser, "Missing catch or "
- "finally after try", NULL);
+ njs_parser_syntax_error(vm, parser,
+ "Missing catch or finally after try", NULL);
return NJS_TOKEN_ILLEGAL;
}
p = trace->handler(trace, td, p);
if (vm->parser != NULL) {
- njs_exception_internal_error(vm, "%s in %u", start,
- vm->parser->lexer->line);
+ njs_internal_error(vm, "%s in %u", start, vm->parser->lexer->line);
} else {
- njs_exception_internal_error(vm, "%s", start);
+ njs_internal_error(vm, "%s", start);
}
return p;
(void) vsnprintf(buf, sizeof(buf), fmt, args);
va_end(args);
- njs_exception_syntax_error(vm, "%s in %u", buf, parser->lexer->line);
+ njs_syntax_error(vm, "%s in %u", buf, parser->lexer->line);
}
(void) vsnprintf(buf, sizeof(buf), fmt, args);
va_end(args);
- njs_exception_ref_error(vm, "%s in %u", buf, parser->lexer->line);
+ njs_reference_error(vm, "%s in %u", buf, parser->lexer->line);
}
}
if (!njs_parser_is_lvalue(parser->node)) {
- njs_parser_ref_error(vm, parser, "Invalid left-hand side "
- "in assignment", NULL);
+ njs_parser_ref_error(vm, parser,
+ "Invalid left-hand side in assignment", NULL);
return NJS_TOKEN_ILLEGAL;
}
}
if (!njs_parser_is_lvalue(parser->node)) {
- njs_parser_ref_error(vm, parser, "Invalid left-hand side "
- "in prefix operation", NULL);
+ njs_parser_ref_error(vm, parser,
+ "Invalid left-hand side in prefix operation",
+ NULL);
return NJS_TOKEN_ILLEGAL;
}
}
if (!njs_parser_is_lvalue(parser->node)) {
- njs_parser_ref_error(vm, parser, "Invalid left-hand side "
- "in postfix operation", NULL);
+ njs_parser_ref_error(vm, parser,
+ "Invalid left-hand side in postfix operation",
+ NULL);
return NJS_TOKEN_ILLEGAL;
}
if (nxt_fast_path(ret >= 0)) {
if (nxt_slow_path((u_int) ret != pattern->ncaptures)) {
- njs_exception_internal_error(vm, NULL, NULL);
+ njs_internal_error(vm, NULL, NULL);
nxt_mem_cache_free(vm->mem_cache_pool, pattern);
return NULL;
}
p = trace->handler(trace, td, start);
if (vm->parser != NULL) {
- njs_exception_syntax_error(vm, "%s in %u", start,
- vm->parser->lexer->line);
+ njs_syntax_error(vm, "%s in %u", start, vm->parser->lexer->line);
} else {
- njs_exception_syntax_error(vm, "%s", start);
+ njs_syntax_error(vm, "%s", start);
}
return p;
trace = trace->next;
p = trace->handler(trace, td, start);
- njs_exception_internal_error(vm, (const char *) start, NULL);
+ njs_internal_error(vm, (const char *) start, NULL);
return p;
}
return njs_regexp_string_create(vm, &vm->retval, source, size, length);
}
- njs_exception_type_error(vm, "'this' argument is not a regexp", NULL);
+ njs_type_error(vm, "'this' argument is not a regexp", NULL);
return NXT_ERROR;
}
njs_regexp_pattern_t *pattern;
if (!njs_is_regexp(&args[0])) {
- njs_exception_type_error(vm, "'this' argument is not a regexp", NULL);
+ njs_type_error(vm, "'this' argument is not a regexp", NULL);
return NXT_ERROR;
}
nxt_regex_match_data_t *match_data;
if (!njs_is_regexp(&args[0])) {
- njs_exception_type_error(vm, "'this' argument is not a regexp", NULL);
+ njs_type_error(vm, "'this' argument is not a regexp", NULL);
return NXT_ERROR;
}
value = &value->data.u.object_value->value;
} else {
- njs_exception_type_error(vm, "unexpected value type:%s",
- njs_type_string(value->type));
+ njs_type_error(vm, "unexpected value type:%s",
+ njs_type_string(value->type));
return NXT_ERROR;
}
}
njs_string_prop_t string;
if (njs_is_null_or_void(&args[0])) {
- njs_exception_type_error(vm, "'this' argument is null or undefined",
- NULL);
+ njs_type_error(vm, "'this' argument is null or undefined", NULL);
return NXT_ERROR;
}
range_error:
- njs_exception_range_error(vm, NULL, NULL);
+ njs_range_error(vm, NULL, NULL);
return NXT_ERROR;
}
n = args[1].data.u.number;
if (nxt_slow_path(n < 0 || n >= max)) {
- njs_exception_range_error(vm, NULL, NULL);
+ njs_range_error(vm, NULL, NULL);
return NXT_ERROR;
}
}
nxt_regex_match_data_free(r->match_data, vm->regex_context);
- njs_exception_internal_error(vm, "unexpected continuation retval type:%s",
- njs_type_string(r->retval.type));
+ njs_internal_error(vm, "unexpected continuation retval type:%s",
+ njs_type_string(r->retval.type));
return NXT_ERROR;
}
return njs_string_replace_join(vm, r);
}
- njs_exception_internal_error(vm, "unexpected continuation retval type:%s",
- njs_type_string(r->retval.type));
+ njs_internal_error(vm, "unexpected continuation retval type:%s",
+ njs_type_string(r->retval.type));
return NXT_ERROR;
}
data = nxt_mem_cache_alloc(vm->mem_cache_pool, size + 1);
if (nxt_slow_path(data == NULL)) {
- njs_exception_memory_error(vm);
+ njs_memory_error(vm);
return NULL;
}
uri_error:
- njs_exception_uri_error(vm, NULL, NULL);
+ njs_uri_error(vm, NULL, NULL);
return NXT_ERROR;
}
njs_vm_ops_t *ops;
if (nxt_slow_path(nargs < 2)) {
- njs_exception_type_error(vm, "too few arguments", NULL);
+ njs_type_error(vm, "too few arguments", NULL);
return NJS_ERROR;
}
if (nxt_slow_path(!njs_is_function(&args[1]))) {
- njs_exception_type_error(vm, "first arg must be a function", NULL);
+ njs_type_error(vm, "first arg must be a function", NULL);
return NJS_ERROR;
}
ops = vm->ops;
if (nxt_slow_path(ops == NULL)) {
- njs_exception_internal_error(vm, "not supported by host environment",
- NULL);
+ njs_internal_error(vm, "not supported by host environment", NULL);
return NJS_ERROR;
}
event->host_event = ops->set_timer(vm->external, delay, event);
if (event->host_event == NULL) {
- njs_exception_internal_error(vm, "set_timer() failed", NULL);
+ njs_internal_error(vm, "set_timer() failed", NULL);
return NJS_ERROR;
}
memory_error:
- njs_exception_memory_error(vm);
+ njs_memory_error(vm);
return NJS_ERROR;
}
index = (index >> NJS_SCOPE_SHIFT) + 1;
if (index > 255 || vs.scope->argument_closures == 0) {
- njs_exception_internal_error(vm, "too many argument closures",
- NULL);
+ njs_internal_error(vm, "too many argument closures", NULL);
return NULL;
}
njs_vmcode_prop_set_t *code;
if (njs_is_primitive(object)) {
- njs_exception_type_error(vm, "property set on primitive %s type",
- njs_type_string(object->type));
+ njs_type_error(vm, "property set on primitive %s type",
+ njs_type_string(object->type));
return NXT_ERROR;
}
case NJS_PRIMITIVE_VALUE:
case NJS_STRING_VALUE:
- njs_exception_type_error(vm, "property in on a primitive value", NULL);
+ njs_type_error(vm, "property in on a primitive value", NULL);
return NXT_ERROR;
if (nxt_fast_path(ret == NXT_OK)) {
njs_string_get(&pq->value, &pq->lhq.key);
- njs_exception_type_error(vm,
- "cannot get property '%.*s' of undefined",
- (int) pq->lhq.key.length,
- pq->lhq.key.start);
+ njs_type_error(vm, "cannot get property '%.*s' of undefined",
+ (int) pq->lhq.key.length, pq->lhq.key.start);
return NXT_ERROR;
}
}
- njs_exception_type_error(vm,
- "cannot get property 'unknown' of undefined", NULL);
+ njs_type_error(vm, "cannot get property 'unknown' of undefined", NULL);
return NXT_ERROR;
}
static njs_value_t prototype_string = njs_string("prototype");
if (!njs_is_function(constructor)) {
- njs_exception_type_error(vm, "right argument is not a function", NULL);
+ njs_type_error(vm, "right argument is not a function", NULL);
return NXT_ERROR;
}
}
}
- njs_exception_type_error(vm, "object is not callable", NULL);
+ njs_type_error(vm, "object is not callable", NULL);
return NXT_ERROR;
}
ret = nxt_lvlhsh_find(&ext_proto->hash, &pq.lhq);
if (nxt_slow_path(ret != NXT_OK)) {
- njs_exception_type_error(vm,
- "cannot find property '%.*s' of an external object",
- (int) pq.lhq.key.length, pq.lhq.key.start);
+ njs_type_error(vm,
+ "cannot find property '%.*s' of an external object",
+ (int) pq.lhq.key.length, pq.lhq.key.start);
return NXT_ERROR;
}
ext_proto = pq.lhq.value;
if (nxt_slow_path(ext_proto->type != NJS_EXTERN_METHOD)) {
- njs_exception_type_error(vm,
+ njs_type_error(vm,
"method '%.*s' of an external object is not callable",
(int) pq.lhq.key.length, pq.lhq.key.start);
return NXT_ERROR;
return NXT_ERROR;
default:
- njs_exception_internal_error(vm, "method '%.*s' query failed:%d",
- (int) pq.lhq.key.length, pq.lhq.key.start,
- ret);
+ njs_internal_error(vm, "method '%.*s' query failed:%d",
+ (int) pq.lhq.key.length, pq.lhq.key.start, ret);
return NXT_ERROR;
}
type_error:
- njs_exception_type_error(vm, "cannot convert %s to %s",
- njs_type_string(args->type),
- njs_arg_type_string(*args_types));
+ njs_type_error(vm, "cannot convert %s to %s", njs_type_string(args->type),
+ njs_arg_type_string(*args_types));
return NXT_ERROR;
}
}
if (ret == NXT_ERROR) {
- njs_exception_type_error(vm, "cannot evaluate an object's "
- "value", NULL);
+ njs_type_error(vm, "cannot evaluate an object's value",
+ NULL);
}
return ret;