{"action":"created","issue":{"url":"https://api.github.com/repos/ellzey/libevhtp/issues/160","labels_url":"https://api.github.com/repos/ellzey/libevhtp/issues/160/labels{/name}","comments_url":"https://api.github.com/repos/ellzey/libevhtp/issues/160/comments","events_url":"https://api.github.com/repos/ellzey/libevhtp/issues/160/events","html_url":"https://github.com/ellzey/libevhtp/issues/160","id":63627279,"number":160,"title":"How to use evhtp_hook_on_error to get to know the errors ","user":{"login":"niks3089","id":5587829,"avatar_url":"https://avatars.githubusercontent.com/u/5587829?v=3","gravatar_id":"","url":"https://api.github.com/users/niks3089","html_url":"https://github.com/niks3089","followers_url":"https://api.github.com/users/niks3089/followers","following_url":"https://api.github.com/users/niks3089/following{/other_user}","gists_url":"https://api.github.com/users/niks3089/gists{/gist_id}","starred_url":"https://api.github.com/users/niks3089/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/niks3089/subscriptions","organizations_url":"https://api.github.com/users/niks3089/orgs","repos_url":"https://api.github.com/users/niks3089/repos","events_url":"https://api.github.com/users/niks3089/events{/privacy}","received_events_url":"https://api.github.com/users/niks3089/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":12,"created_at":"2015-03-23T05:08:32Z","updated_at":"2015-03-24T07:14:25Z","closed_at":null,"body":"I am writing a client program using libevhtp, I would like to know the errors that could happen,  for example, I have stopped httpd daemon so I get connection refused error. How do I get the various server error? \r\n\r\nHow do I use evhtp_hook_on_error ? I don't see this used anywhere in the example.\r\n\r\nAlso, when I pass a callback argument to the  evhtp_hook_on_error , the argument is not passed correctly to the callback and the program crashes. \r\n\r\nFollowing is the GDB snippet, as you can see, I am passing \"conn\" as the argument i but in the callback it is NULL and on the other hooks, I get the argument correctly\r\n```\r\nBreakpoint 1, http_connection_fsm_state_init (conn=0x7fffe8005628) at /home/nikhil/trunk/src/http/http_connection_fsm.c:209\r\n209         evhtp_set_hook(&conn->ev_req->hooks, evhtp_hook_on_error,\r\n(gdb) p *conn\r\n$1 = {ev_conn = 0x7fffe8005850, ev_req = 0x7fffe8007ce0, status = 0, base = 0x7fffe80046a0, active_link = {dll_next = 0x7fffe8005618,\r\n    dll_prev = 0x7fffe8005618}, conn_id = 0, requests_sent = 0, requests_completed = 0, is_https = 0 '\\000', done = 0 '\\000', reserved = 0 '\\000',\r\n  error = 0, error_msg = 0x0, state = HTTP_CONN_STATE_INIT, stats = {http_code_success = 0 '\\000', http_transfer_error = 0 '\\000',\r\n    http_internal_error = 0 '\\000', http_code_unused = 0 '\\000', http_code_1xx = 0, http_code_2xx = 0, http_code_3xx = 0, http_code_4xx = 0,\r\n    http_code_5xx = 0, total_transfer_time = 0, name_lookup_time = 0, connect_time = 0, app_connect_time = 0, pretransfer_time = 0,\r\n    starttransfer_time = 0, redirect_time = 0, redirect_count = 0, uploaded_bytes = 0, upload_speed = 0, downloaded_bytes = 0, download_speed = 0,\r\n    total_header_size = 0, total_request_size = 0, ssl_verify_result = 0, total_connects = 0, total_requests = 0, requests_sent = 0,\r\n    requests_attempted = 0, requests_completed = 0, start_time = 1427086597, run_time = 0}}\r\n(gdb) c\r\nContinuing.\r\n\r\nBreakpoint 2, http_connection_fsm_error_cb (req=0x7fffe8007ce0, arg=0x21) at /home/nikhil/trunk/src/http/http_connection_fsm.c:129\r\n129         http_connection_t *conn = (http_connection_t *)arg;\r\n(gdb) p *arg\r\nAttempt to dereference a generic pointer.\r\n(gdb) p *conn\r\nCannot access memory at address 0x0\r\n```"},"comment":{"url":"https://api.github.com/repos/ellzey/libevhtp/issues/comments/85372303","html_url":"https://github.com/ellzey/libevhtp/issues/160#issuecomment-85372303","issue_url":"https://api.github.com/repos/ellzey/libevhtp/issues/160","id":85372303,"user":{"login":"tjeezy","id":109224,"avatar_url":"https://avatars.githubusercontent.com/u/109224?v=3","gravatar_id":"","url":"https://api.github.com/users/tjeezy","html_url":"https://github.com/tjeezy","followers_url":"https://api.github.com/users/tjeezy/followers","following_url":"https://api.github.com/users/tjeezy/following{/other_user}","gists_url":"https://api.github.com/users/tjeezy/gists{/gist_id}","starred_url":"https://api.github.com/users/tjeezy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tjeezy/subscriptions","organizations_url":"https://api.github.com/users/tjeezy/orgs","repos_url":"https://api.github.com/users/tjeezy/repos","events_url":"https://api.github.com/users/tjeezy/events{/privacy}","received_events_url":"https://api.github.com/users/tjeezy/received_events","type":"User","site_admin":false},"created_at":"2015-03-24T07:14:25Z","updated_at":"2015-03-24T07:14:25Z","body":"```\r\nevhtp_set_hook(&conn->ev_conn->hooks, evhtp_hook_on_conn_error,\r\n        (evhtp_hook)error_cb, temp);\r\n```"}}