Loading [MathJax]/extensions/tex2jax.js
www.mooseframework.org
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends
MooseException.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 };
StreamArguments.h
MooseException
Provides a way for users to bail out of the current solve.
Definition: MooseException.h:20
MooseException::_message
std::string _message
Definition: MooseException.h:63
MooseException::MooseException
MooseException(std::string message)
Definition: MooseException.h:26
MooseException::~MooseException
~MooseException()
For some reason, on GCC 4.6.3, I get 'error: looser throw specifier' when deriving from std::exceptio...
Definition: MooseException.h:53
MooseException::what
virtual const char * what() const
Get out the error message.
Definition: MooseException.h:60
streamArguments
void streamArguments(StreamType &)
Definition: StreamArguments.h:16
MooseException::MooseException
MooseException(Args &&... args)
Definition: MooseException.h:39