Skip to content
This repository has been archived by the owner on Nov 6, 2022. It is now read-only.

Error handling: how to get specific error messages? #476

Closed
wonter opened this issue Apr 28, 2019 · 5 comments
Closed

Error handling: how to get specific error messages? #476

wonter opened this issue Apr 28, 2019 · 5 comments

Comments

@wonter
Copy link

wonter commented Apr 28, 2019

I found the basic error handling in README:

if (parser->upgrade) {
  /* handle new protocol */
} else if (nparsed != recved) {
  /* Handle error. Usually just close the connection. */
}

But how can I get more specific error messages?

Something like invalid HTTP method error message.

@wonter wonter changed the title Error handling Error handling: how to get specific error messages? Apr 28, 2019
@ploxiln
Copy link
Contributor

ploxiln commented Apr 28, 2019

try:

const char *err_name = http_errno_name(HTTP_PARSER_ERRNO(parser));
const char *err_desc = http_errno_description(HTTP_PARSER_ERRNO(parser));

@wonter wonter closed this as completed Apr 28, 2019
@wonter wonter reopened this Apr 28, 2019
@wonter
Copy link
Author

wonter commented Apr 28, 2019

try:

const char *err_name = http_errno_name(HTTP_PARSER_ERRNO(parser));
const char *err_desc = http_errno_description(HTTP_PARSER_ERRNO(parser));

@ploxiln

Sorry, I have another question.

Is HTTP_PARSER_ERRNO(parser) always be set when an error occurred??

I mean, will HTTP_PARSER_ERRNO(parser) be set when nparsed != recved?

@ploxiln
Copy link
Contributor

ploxiln commented Apr 29, 2019

yes

@ploxiln
Copy link
Contributor

ploxiln commented Apr 29, 2019

to be sure you can check if (HTTP_PARSER_ERRNO(parser) != 0)

@wonter
Copy link
Author

wonter commented Apr 30, 2019

to be sure you can check if (HTTP_PARSER_ERRNO(parser) != 0)

thx!

@wonter wonter closed this as completed Apr 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants