https://mooseframework.inl.gov
MooseException.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #pragma once
11 
12 #include "StreamArguments.h"
13 
14 #include <exception>
15 #include <sstream>
16 
20 class MooseException : public std::exception
21 {
22 public:
26  MooseException(std::string message) : _message(message) {}
27 
32  MooseException(const MooseException &) = default;
33 
38  template <typename... Args>
39  explicit MooseException(Args &&... args)
40  {
41  std::ostringstream ss;
42  streamArguments(ss, args...);
43  _message = ss.str();
44  }
45 
53  ~MooseException() throw() {}
54 
60  virtual const char * what() const throw() { return _message.c_str(); }
61 
62 protected:
63  std::string _message;
64 };
virtual const char * what() const
Get out the error message.
void streamArguments(StreamType &)
MooseException(std::string message)
MooseException(Args &&... args)
Provides a way for users to bail out of the current solve.
std::string _message
~MooseException()
For some reason, on GCC 4.6.3, I get &#39;error: looser throw specifier&#39; when deriving from std::exceptio...