if (JS_IsString(input)) {
rc = ngx_qjs_string(cx, pool, input, &request->url);
if (rc != NGX_OK) {
- JS_ThrowInternalError(cx, "failed to convert url arg");
+ if (!JS_HasException(cx)) {
+ JS_ThrowOutOfMemory(cx);
+ }
+
return NGX_ERROR;
}
} else {
- orig = JS_GetOpaque2(cx, input, NGX_QJS_CLASS_ID_FETCH_REQUEST);
+ orig = JS_GetOpaque(input, NGX_QJS_CLASS_ID_FETCH_REQUEST);
if (orig == NULL) {
JS_ThrowInternalError(cx,
"input is not string or a Request object");
JS_FreeValue(cx, value);
if (rc != NGX_OK) {
- JS_ThrowInternalError(cx, "invalid Request method");
+ if (!JS_HasException(cx)) {
+ JS_ThrowOutOfMemory(cx);
+ }
+
return NGX_ERROR;
}
}
if (!JS_IsUndefined(value)) {
if (!JS_IsObject(value)) {
+ JS_FreeValue(cx, value);
JS_ThrowInternalError(cx, "Headers is not an object");
return NGX_ERROR;
}
if (!JS_IsUndefined(value)) {
if (ngx_qjs_string(cx, pool, value, &request->body) != NGX_OK) {
JS_FreeValue(cx, value);
- JS_ThrowInternalError(cx, "invalid Request body");
+ if (!JS_HasException(cx)) {
+ JS_ThrowOutOfMemory(cx);
+ }
+
return NGX_ERROR;
}
JS_FreeValue(cx, value);
if (ret < 0) {
+ if (!JS_HasException(cx)) {
+ JS_ThrowOutOfMemory(cx);
+ }
+
return JS_EXCEPTION;
}
pool = ngx_qjs_external_pool(cx, JS_GetContextOpaque(cx));
if (ngx_qjs_string(cx, pool, prop_name, &name) != NGX_OK) {
+ if (!JS_HasException(cx)) {
+ JS_ThrowOutOfMemory(cx);
+ }
+
JS_FreeValue(cx, prop_name);
JS_FreeValue(cx, prop_value);
return NGX_ERROR;
}
if (ngx_qjs_string(cx, pool, prop_value, &value) != NGX_OK) {
+ if (!JS_HasException(cx)) {
+ JS_ThrowOutOfMemory(cx);
+ }
+
JS_FreeValue(cx, prop_name);
JS_FreeValue(cx, prop_value);
return NGX_ERROR;
JSPropertyEnum *tab;
ngx_js_headers_t *hh;
- hh = JS_GetOpaque2(cx, init, NGX_QJS_CLASS_ID_FETCH_HEADERS);
+ hh = JS_GetOpaque(init, NGX_QJS_CLASS_ID_FETCH_HEADERS);
if (hh != NULL) {
return ngx_qjs_headers_inherit(cx, headers, hh);
}