Skip to content
Snippets Groups Projects
Commit 107c9e50 authored by Stéphane Poirier's avatar Stéphane Poirier
Browse files

Formatter for Error class

parent 14849a2b
Branches
Tags
No related merge requests found
...@@ -1679,6 +1679,34 @@ struct Format::Formatter< SharedPtr<T,L> > ...@@ -1679,6 +1679,34 @@ struct Format::Formatter< SharedPtr<T,L> >
} }
}; };
//==================================================================================================
//! \brief for using with yat::Error class
//!
//! No specific format syntax defined for this formatter\n
//! Output the three values of an exception\n
//==================================================================================================
template <>
struct Format::Formatter<Error>
{
void operator()(const Error& err, std::ostream &oss, const Format::Context& fc)
{
// setup width & alignment
prepare_format(oss, fc, 's');
if( !fc.fmt_ext.empty() )
{
if( fc.fmt_ext[0] == 'r' )
oss << err.reason;
else if( fc.fmt_ext[0] == 'd' )
oss << err.desc;
else if( fc.fmt_ext[0] == 'o' )
oss << err.origin;
}
else
oss << "what: " << err.reason << ". why: " << err.desc << ". where: " << err.origin;
}
};
//! @deprecated original class name //! @deprecated original class name
typedef Format StringFormat; typedef Format StringFormat;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment