Skip to content

Catching http request errors in Node.js  #185

@OneHwang

Description

@OneHwang

The solution to the content negotiation problem suggests http request errors can be caught through the following:

readStreamAsString(response, function(error, content) { if (error) throw error;
However, if the bogus "application/rainbows+unicorns" is included as a data type in the request to eloquentjavascript.net/author, Node.js does NOT throw an error. Instead, it appears to treat the response from the server like regular content, and prints the following:

`

<title>406 Not Acceptable</title>

406 Not Acceptable


nginx/1.6.2 `

It would be useful if 1) you could explain why browser consoles recognize this error, but Node.js does not and 2) you could provide a solution that would catch this error in Node.js.

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions