aboutsummaryrefslogtreecommitdiff
path: root/brep
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-04-15 09:10:10 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-04-15 09:10:10 +0200
commita96a346e4ab58729b1f257268f2d2af1ebdca890 (patch)
tree73ad795433a1efd2f7a2a341e18f83f7d3c0c837 /brep
parent17683bcc74284c344dc67f5a9b806801af5c598f (diff)
Misc compilation fixes
Diffstat (limited to 'brep')
-rw-r--r--brep/diagnostics4
-rw-r--r--brep/diagnostics.cxx2
-rw-r--r--brep/module24
-rw-r--r--brep/module.cxx3
-rw-r--r--brep/search.cxx4
5 files changed, 23 insertions, 14 deletions
diff --git a/brep/diagnostics b/brep/diagnostics
index 70ddb2a..094a62b 100644
--- a/brep/diagnostics
+++ b/brep/diagnostics
@@ -233,7 +233,7 @@ namespace brep
const diag_epilogue& e,
const char* name = nullptr,
const void* data = nullptr)
- : sev_ (s), epilogue (e), name_ (name), data_ (data) {}
+ : sev_ (s), epilogue_ (e), name_ (name), data_ (data) {}
simple_prologue
operator() () const
@@ -289,7 +289,7 @@ namespace brep
operator() (const L& l) const
{
return location_prologue (
- epilogue_, severity::error, name, get_location (l, data_));
+ epilogue_, severity::error, name_, get_location (l, data_));
}
static void
diff --git a/brep/diagnostics.cxx b/brep/diagnostics.cxx
index 5ab34b6..36d409f 100644
--- a/brep/diagnostics.cxx
+++ b/brep/diagnostics.cxx
@@ -9,7 +9,7 @@
using namespace std;
-namespace build
+namespace brep
{
diag_record::
~diag_record () noexcept(false)
diff --git a/brep/module b/brep/module
index dfcf7ad..f6144f2 100644
--- a/brep/module
+++ b/brep/module
@@ -6,6 +6,7 @@
#define BREP_MODULE
#include <brep/diagnostics>
+#include <web/module>
namespace brep
{
@@ -21,6 +22,8 @@ namespace brep
//@@ Maybe optional "try again" link?
//
+ invalid_request (const char* d, web::status_code s = 422)
+ : status (s), description (d) {}
};
// And this exception indicated a server error (5XX). In particular,
@@ -31,6 +34,8 @@ namespace brep
struct server_error
{
diag_data data;
+
+ server_error (diag_data&& d) : data (std::move (d)) {}
};
// Every module member function that needs to produce any diagnostics
@@ -46,7 +51,7 @@ namespace brep
const basic_mark error (severity::error, \
this->log_writer_, \
__PRETTY_FUNCTION__); \
- const basic_mark warn (severity::warn, \
+ const basic_mark warn (severity::warning, \
this->log_writer_, \
__PRETTY_FUNCTION__); \
const basic_mark info (severity::info, \
@@ -65,11 +70,13 @@ namespace brep
// There will, however, most likely be a conflict between
// web::module and our module. Or maybe not, need to try.
//
- using status_code;
- using name_value;
- using name_values;
- using request;
- using response;
+
+ using web::status_code;
+ using web::name_value;
+ using web::name_values;
+ using web::request;
+ using web::response;
+ using web::log;
class module: public web::module
{
@@ -90,8 +97,8 @@ namespace brep
//
std::uint16_t verb_ {0};
- template <class F> static void level1 (const F& f) {if (verb_ >= 1) f ();}
- template <class F> static void level2 (const F& f) {if (verb_ >= 2) f ();}
+ template <class F> void level1 (const F& f) const {if (verb_ >= 1) f ();}
+ template <class F> void level2 (const F& f) const {if (verb_ >= 2) f ();}
// Implementation details.
//
@@ -109,6 +116,7 @@ namespace brep
void
log_write (diag_data&&) const;
+ protected:
const diag_epilogue log_writer_;
};
}
diff --git a/brep/module.cxx b/brep/module.cxx
index 3420aa0..8a9d71a 100644
--- a/brep/module.cxx
+++ b/brep/module.cxx
@@ -7,6 +7,7 @@
#include <functional> // bind()
using namespace std;
+using namespace placeholders;
namespace brep
{
@@ -26,7 +27,7 @@ namespace brep
//
rs.content (e.status, "text/html;charset=utf-8") << e.description;
}
- catch (const server_error& e)
+ catch (server_error& e)
{
// @@ Both log and return as 505.
//
diff --git a/brep/search.cxx b/brep/search.cxx
index cc3cee2..683016c 100644
--- a/brep/search.cxx
+++ b/brep/search.cxx
@@ -21,10 +21,10 @@ namespace brep
throw invalid_request ("search parameters expected");
if (ps.size () > 100)
- fail << "too many parameters: " < ps.size () <<
+ fail << "too many parameters: " << ps.size () <<
info << "are you crazy to specify so many?";
- info << "handling search request from " << rq.client_ip ();
+ info << "handling search request from "; // << rq.client_ip ();
level2 ([&]{trace << "search request with " << ps.size () << " params";});