test_exceptions.cxx
Go to the documentation of this file.
2 #include "WireCellUtil/String.h"
3 
4 #include <iostream>
5 
6 using namespace WireCell;
7 using namespace std;
8 
10 
11 
12 int main()
13 {
14  int value = 42;
15  std::string omg = "omg";
16  const double number = 6.9;
17 
18  cerr << format("something") << endl;
19  cerr << format("value=%d", value) << endl;
20  cerr << format("value=%d, omg=\"%s\", number=%f", value, omg, number) << endl;
21 
22 
23  try {
24  THROW(ValueError() << errmsg{format("some error with value=%d msg=\"%s\"", value, omg)});
25  }
26  catch (ValueError& e) {
27  cerr << "caught ValueError: " << errstr(e) << endl;
28  }
29 
30 
31 }
std::string string
Definition: nybbler.cc:12
boost::error_info< struct tag_errmsg, std::string > errmsg
Definition: Exceptions.h:54
STL namespace.
#define errstr(e)
Definition: Exceptions.h:26
const double e
#define THROW(e)
Definition: Exceptions.h:25
Thrown when a wrong value has been encountered.
Definition: Exceptions.h:37
std::string format(const std::string &form, TYPES...objs)
Definition: String.h:45
Definition: Main.h:22
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1225
int main()
QTextStream & endl(QTextStream &s)