https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
20class MooseException : public std::exception
21{
22public:
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
62protected:
63 std::string _message;
64};
void streamArguments(StreamType &)
Provides a way for users to bail out of the current solve.
virtual const char * what() const
Get out the error message.
~MooseException()
For some reason, on GCC 4.6.3, I get 'error: looser throw specifier' when deriving from std::exceptio...
MooseException(const MooseException &)=default
Set an explicit default constructor to avoid the variadic template constructor below catch the copy c...
MooseException(std::string message)
MooseException(Args &&... args)
std::string _message