From 9a81c308f2d4217592630ef41a18a8998bd66f5c Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 6 Jan 2017 03:26:03 +0300 Subject: Add operator<<(ostream, exception) --- butl/fdstream.cxx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'butl/fdstream.cxx') diff --git a/butl/fdstream.cxx b/butl/fdstream.cxx index 2eee7c5..370a75e 100644 --- a/butl/fdstream.cxx +++ b/butl/fdstream.cxx @@ -46,18 +46,22 @@ namespace butl // exception and to make a string returned by what() to contain the error // description plus an optional custom message if provided. Unfortunatelly // there is no way to say that the custom message is absent. Passing an - // empty string results for GCC (as of version 5.3.1) with a description - // like this (note the ugly ": " prefix): ": No such file or directory". + // empty string results for libstdc++ (as of version 5.3.1) with a + // description like this (note the ': ' prefix): + // + // : No such file or directory + // + // Note that our custom operator<<(ostream, exception) strips this prefix. // throw ios_base::failure (m != nullptr ? m : "", e); } template static inline void - throw_ios_failure (error_code ec, + throw_ios_failure (error_code e, typename enable_if::type m) { - throw ios_base::failure (m != nullptr ? m : ec.message ().c_str ()); + throw ios_base::failure (m != nullptr ? m : e.message ().c_str ()); } inline void -- cgit v1.1