-#define ngx_js_http_error(http, err, fmt, ...) \
+#define ngx_js_http_error(http, fmt, ...) \
do { \
njs_vm_error((http)->vm, fmt, ##__VA_ARGS__); \
njs_vm_exception_get((http)->vm, \
http = ctx->data;
if (ctx->state) {
- ngx_js_http_error(http, 0, "\"%V\" could not be resolved (%i: %s)",
+ ngx_js_http_error(http, "\"%V\" could not be resolved (%i: %s)",
&ctx->name, ctx->state,
ngx_resolver_strerror(ctx->state));
return;
failed:
- ngx_js_http_error(http, 0, "memory error");
+ ngx_js_http_error(http, "memory error");
}
rc = ngx_event_connect_peer(&http->peer);
if (rc == NGX_ERROR) {
- ngx_js_http_error(http, 0, "connect failed");
+ ngx_js_http_error(http, "connect failed");
return;
}
if (ngx_ssl_create_connection(http->ssl, c, NGX_SSL_BUFFER|NGX_SSL_CLIENT)
!= NGX_OK)
{
- ngx_js_http_error(http, 0, "failed to create ssl connection");
+ ngx_js_http_error(http, "failed to create ssl connection");
return;
}
c->sendfile = 0;
if (ngx_js_http_ssl_name(http) != NGX_OK) {
- ngx_js_http_error(http, 0, "failed to create ssl connection");
+ ngx_js_http_error(http, "failed to create ssl connection");
return;
}
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, http->log, 0, "js fetch next addr");
if (++http->naddr >= http->naddrs) {
- ngx_js_http_error(http, 0, "connect failed");
+ ngx_js_http_error(http, "connect failed");
return;
}
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, wev->log, 0, "js fetch write handler");
if (wev->timedout) {
- ngx_js_http_error(http, NGX_ETIMEDOUT, "write timed out");
+ ngx_js_http_error(http, "write timed out");
return;
}
if (b == NULL) {
size = njs_chb_size(&http->chain);
if (size < 0) {
- ngx_js_http_error(http, 0, "memory error");
+ ngx_js_http_error(http, "memory error");
return;
}
b = ngx_create_temp_buf(http->pool, size);
if (b == NULL) {
- ngx_js_http_error(http, 0, "memory error");
+ ngx_js_http_error(http, "memory error");
return;
}
}
if (ngx_handle_write_event(wev, 0) != NGX_OK) {
- ngx_js_http_error(http, 0, "write failed");
+ ngx_js_http_error(http, "write failed");
}
return;
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, rev->log, 0, "js fetch read handler");
if (rev->timedout) {
- ngx_js_http_error(http, NGX_ETIMEDOUT, "read timed out");
+ ngx_js_http_error(http, "read timed out");
return;
}
if (http->buffer == NULL) {
b = ngx_create_temp_buf(http->pool, http->buffer_size);
if (b == NULL) {
- ngx_js_http_error(http, 0, "memory error");
+ ngx_js_http_error(http, "memory error");
return;
}
if (n == NGX_AGAIN) {
if (ngx_handle_read_event(rev, 0) != NGX_OK) {
- ngx_js_http_error(http, 0, "read failed");
+ ngx_js_http_error(http, "read failed");
}
return;
}
if (rc == NGX_AGAIN) {
- ngx_js_http_error(http, 0, "prematurely closed connection");
+ ngx_js_http_error(http, "prematurely closed connection");
}
}
/* rc == NGX_ERROR */
- ngx_js_http_error(http, 0, "invalid fetch status line");
+ ngx_js_http_error(http, "invalid fetch status line");
return NGX_ERROR;
}
rc = ngx_list_init(&http->response.headers.header_list, http->pool, 4,
sizeof(ngx_js_tb_elt_t));
if (rc != NGX_OK) {
- ngx_js_http_error(http, 0, "alloc failed");
+ ngx_js_http_error(http, "alloc failed");
return NGX_ERROR;
}
}
hp->header_start, vlen);
if (ret == NJS_ERROR) {
- ngx_js_http_error(http, 0, "cannot add respose header");
+ ngx_js_http_error(http, "cannot add respose header");
return NGX_ERROR;
}
{
hp->content_length_n = ngx_atoof(hp->header_start, vlen);
if (hp->content_length_n == NGX_ERROR) {
- ngx_js_http_error(http, 0, "invalid fetch content length");
+ ngx_js_http_error(http, "invalid fetch content length");
return NGX_ERROR;
}
&& hp->content_length_n
> (off_t) http->max_response_body_size)
{
- ngx_js_http_error(http, 0,
+ ngx_js_http_error(http,
"fetch content length is too large");
return NGX_ERROR;
}
/* rc == NGX_ERROR */
- ngx_js_http_error(http, 0, "invalid fetch header");
+ ngx_js_http_error(http, "invalid fetch header");
return NGX_ERROR;
}
if (http->done) {
size = njs_chb_size(&http->response.chain);
if (size < 0) {
- ngx_js_http_error(http, 0, "memory error");
+ ngx_js_http_error(http, "memory error");
return NGX_ERROR;
}
&& http->http_parse.chunked
&& http->http_parse.content_length_n == -1)
{
- ngx_js_http_error(http, 0, "invalid fetch chunked response");
+ ngx_js_http_error(http, "invalid fetch chunked response");
return NGX_ERROR;
}
ngx_http_js_fetch_response_proto_id,
&http->response, 0);
if (ret != NJS_OK) {
- ngx_js_http_error(http, 0, "fetch response creation failed");
+ ngx_js_http_error(http, "fetch response creation failed");
return NGX_ERROR;
}
return NGX_AGAIN;
}
- ngx_js_http_error(http, 0, "fetch trailing data");
+ ngx_js_http_error(http, "fetch trailing data");
return NGX_ERROR;
}
rc = ngx_js_http_parse_chunked(&http->http_chunk_parse, b,
&http->response.chain);
if (rc == NGX_ERROR) {
- ngx_js_http_error(http, 0, "invalid fetch chunked response");
+ ngx_js_http_error(http, "invalid fetch chunked response");
return NGX_ERROR;
}
}
if (size > http->max_response_body_size * 10) {
- ngx_js_http_error(http, 0, "very large fetch chunked response");
+ ngx_js_http_error(http, "very large fetch chunked response");
return NGX_ERROR;
}
chsize = ngx_min(need, b->last - b->pos);
if (size + chsize > http->max_response_body_size) {
- ngx_js_http_error(http, 0, "fetch response body is too large");
+ ngx_js_http_error(http, "fetch response body is too large");
return NGX_ERROR;
}
if (http->chunk == NULL) {
b = ngx_create_temp_buf(http->pool, http->buffer_size);
if (b == NULL) {
- ngx_js_http_error(http, 0, "memory error");
+ ngx_js_http_error(http, "memory error");
return NGX_ERROR;
}