aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build2/b-options.cxx3
-rw-r--r--build2/b-options.hxx7
-rw-r--r--build2/b-options.ixx13
3 files changed, 20 insertions, 3 deletions
diff --git a/build2/b-options.cxx b/build2/b-options.cxx
index df39b2b..9b5e427 100644
--- a/build2/b-options.cxx
+++ b/build2/b-options.cxx
@@ -94,6 +94,9 @@ namespace build2
{
os << "invalid value '" << value ().c_str () << "' for option '"
<< option ().c_str () << "'";
+
+ if (!message ().empty ())
+ os << ": " << message ().c_str ();
}
const char* invalid_value::
diff --git a/build2/b-options.hxx b/build2/b-options.hxx
index c9eed77..f3ba750 100644
--- a/build2/b-options.hxx
+++ b/build2/b-options.hxx
@@ -155,7 +155,8 @@ namespace build2
~invalid_value () throw ();
invalid_value (const std::string& option,
- const std::string& value);
+ const std::string& value,
+ const std::string& message = std::string ());
const std::string&
option () const;
@@ -163,6 +164,9 @@ namespace build2
const std::string&
value () const;
+ const std::string&
+ message () const;
+
virtual void
print (::std::ostream&) const;
@@ -172,6 +176,7 @@ namespace build2
private:
std::string option_;
std::string value_;
+ std::string message_;
};
class eos_reached: public exception
diff --git a/build2/b-options.ixx b/build2/b-options.ixx
index 0691f12..0749e4d 100644
--- a/build2/b-options.ixx
+++ b/build2/b-options.ixx
@@ -86,8 +86,11 @@ namespace build2
//
inline invalid_value::
invalid_value (const std::string& option,
- const std::string& value)
- : option_ (option), value_ (value)
+ const std::string& value,
+ const std::string& message)
+ : option_ (option),
+ value_ (value),
+ message_ (message)
{
}
@@ -103,6 +106,12 @@ namespace build2
return value_;
}
+ inline const std::string& invalid_value::
+ message () const
+ {
+ return message_;
+ }
+
// file_io_failure
//
inline file_io_failure::