Throw logic_error in handler

http_handler is part of library, so it must throw exception when error has occured, not write to stderr.