auto bytes = boost::asio::write(socket, boost::asio::buffer(buf, len), ec);
if (ec) {
derr << "write_data failed with " << ec.message() << dendl;
- throw RGWRestfulIOEngine::Exception(-ec.value());
+ throw RGWRestfulIOEngine::Exception(ec.value(), std::system_category());
}
return bytes;
}
const int ret = mg_write(conn, buf, len);
if (ret == 0) {
/* didn't send anything, error out */
- throw RGWRestfulIOEngine::Exception(-EIO);
+ throw RGWRestfulIOEngine::Exception(EIO, std::system_category());
} else if (ret < 0) {
- throw RGWRestfulIOEngine::Exception(ret);
+ throw RGWRestfulIOEngine::Exception(-ret, std::system_category());
}
return ret;
}
{
const int ret = mg_read(conn, buf, len);
if (ret < 0) {
- throw RGWRestfulIOEngine::Exception(ret);
+ throw RGWRestfulIOEngine::Exception(-ret, std::system_category());
}
return ret;
}
const int ret = mg_printf(std::forward<Args>(args)...);
if (ret == 0) {
/* didn't send anything, error out */
- throw RGWRestfulIOEngine::Exception(-EIO);
+ throw RGWRestfulIOEngine::Exception(EIO, std::system_category());
} else if (ret < 0) {
- throw RGWRestfulIOEngine::Exception(ret);
+ throw RGWRestfulIOEngine::Exception(-ret, std::system_category());
}
return static_cast<std::size_t>(ret);
}
}
return sent;
} catch (RGWRestfulIOEngine::Exception& e) {
- return e.value();
+ return -e.code().value();
}
}
#include <streambuf>
#include <istream>
#include <stdlib.h>
+#include <system_error>
#include <boost/utility/string_ref.hpp>
template<typename T> friend class RGWDecoratedRestfulIO;
public:
- class Exception : public std::exception {
- int err;
- public:
- Exception(const int err)
- : err(err) {
- }
-
- int value() {
- return err;
- }
- };
+ typedef std::system_error Exception;
virtual std::size_t send_status(int status, const char *status_name) = 0;
virtual std::size_t send_100_continue() = 0;
// vim: ts=8 sw=2 smarttab
#include "rgw_fcgi.h"
-
#include "acconfig.h"
std::size_t RGWFCGX::write_data(const char* const buf, const std::size_t len)
{
const auto ret = FCGX_PutStr(buf, len, fcgx->out);
if (ret < 0) {
- throw RGWRestfulIOEngine::Exception(ret);
+ throw RGWRestfulIOEngine::Exception(-ret, std::system_category());
}
return ret;
}
{
const auto ret = FCGX_GetStr(buf, len, fcgx->in);
if (ret < 0) {
- throw RGWRestfulIOEngine::Exception(ret);
+ throw RGWRestfulIOEngine::Exception(-ret, std::system_category());
}
return ret;
}
RESTFUL_IO(s)->send_status(status, status_name);
} catch (RGWRestfulIOEngine::Exception& e) {
ldout(s->cct, 0) << "ERROR: s->cio->send_status() returned err="
- << e.value() << dendl;
+ << e.what() << dendl;
}
}
RESTFUL_IO(s)->send_header(name, val);
} catch (RGWRestfulIOEngine::Exception& e) {
ldout(s->cct, 0) << "ERROR: s->cio->send_header() returned err="
- << e.value() << dendl;
+ << e.what() << dendl;
}
}
RESTFUL_IO(s)->send_content_length(len);
} catch (RGWRestfulIOEngine::Exception& e) {
ldout(s->cct, 0) << "ERROR: s->cio->send_content_length() returned err="
- << e.value() << dendl;
+ << e.what() << dendl;
}
dump_header(s, "Accept-Ranges", "bytes");
}
RESTFUL_IO(s)->complete_header();
} catch (RGWRestfulIOEngine::Exception& e) {
ldout(s->cct, 0) << "ERROR: RESTFUL_IO(s)->complete_header() returned err="
- << e.value() << dendl;
+ << e.what() << dendl;
}
ACCOUNTING_IO(s)->set_account(true);
RESTFUL_IO(s)->send_100_continue();
} catch (RGWRestfulIOEngine::Exception& e) {
ldout(s->cct, 0) << "ERROR: RESTFUL_IO(s)->send_100_continue() returned err="
- << e.value() << dendl;
+ << e.what() << dendl;
}
}
try {
return RESTFUL_IO(s)->send_body(buf, len);
} catch (RGWRestfulIOEngine::Exception& e) {
- return e.value();
+ return -e.code().value();
}
}
try {
return RESTFUL_IO(s)->recv_body(buf, max, s->aws4_auth_needs_complete);
} catch (RGWRestfulIOEngine::Exception& e) {
- return e.value();
+ return -e.code().value();
}
}