aboutsummaryrefslogtreecommitdiff
path: root/butl/utility
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2017-01-06 03:26:03 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2017-01-09 21:31:14 +0300
commit9a81c308f2d4217592630ef41a18a8998bd66f5c (patch)
treee5ab252f90d1b3aa2a2f2775f0f36e569d48b4a5 /butl/utility
parent39101a4383d38c1217c44b999a6e3bd199727c60 (diff)
Add operator<<(ostream, exception)
Diffstat (limited to 'butl/utility')
-rw-r--r--butl/utility15
1 files changed, 14 insertions, 1 deletions
diff --git a/butl/utility b/butl/utility
index f668ecc..ac94171 100644
--- a/butl/utility
+++ b/butl/utility
@@ -6,10 +6,11 @@
#define BUTL_UTILITY
#include <string>
+#include <iosfwd> // ostream
#include <cstddef> // size_t
#include <utility> // move(), forward()
#include <cstring> // strcmp(), strlen()
-#include <exception> // uncaught_exception(s)()
+#include <exception> // exception, uncaught_exception(s)()
//#include <functional> // hash
#include <butl/export>
@@ -227,6 +228,18 @@ namespace butl
#endif
}
+namespace std
+{
+ // Sanitize the exception description before printing. This includes:
+ //
+ // - stripping leading colons and spaces (see fdstream.cxx)
+ // - stripping trailing newlines, periods, and spaces
+ // - lower-case the first letter if the beginning looks like a word
+ //
+ LIBBUTL_EXPORT ostream&
+ operator<< (ostream&, const exception&);
+}
+
#include <butl/utility.ixx>
#endif // BUTL_UTILITY