UQTk: Uncertainty Quantification Toolkit 3.1.5
MyException.h
Go to the documentation of this file.
1/* =====================================================================================
2
3 The UQ Toolkit (UQTk) version 3.1.5
4 Copyright (2024) NTESS
5 https://www.sandia.gov/UQToolkit/
6 https://github.com/sandialabs/UQTk
7
8 Copyright 2024 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
9 Under the terms of Contract DE-NA0003525 with NTESS, the U.S. Government
10 retains certain rights in this software.
11
12 This file is part of The UQ Toolkit (UQTk)
13
14 UQTk is open source software: you can redistribute it and/or modify
15 it under the terms of BSD 3-Clause License
16
17 UQTk is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 BSD 3 Clause License for more details.
21
22 You should have received a copy of the BSD 3 Clause License
23 along with UQTk. If not, see https://choosealicense.com/licenses/bsd-3-clause/.
24
25 Questions? Contact the UQTk Developers at https://github.com/sandialabs/UQTk/discussions
26 Sandia National Laboratories, Livermore, CA, USA
27===================================================================================== */
28// -*- C++ -*-
29
30#ifndef _MyException_
31#define _MyException_
32
33#include <iostream>
34#include <exception>
35#include <string.h>
36
40class MyException : public std::exception {
41public:
43 MyException(const char* errormessage) {
44 std::cerr << "ERROR: " << errormessage << "\n";
45 error_ = std::string("MyException: ") + errormessage;
46 }
47
49 MyException(const std::string& errormessage) {
50 std::cerr << "ERROR: " << errormessage << "\n";
51 error_ = std::string("MyException: ") + errormessage;
52 }
53
55 virtual ~MyException() throw() {
56 }
57
59 const char* what() const throw() {
60 try {
61 return error_.c_str();
62 } catch(...) {
63 ;
64 }
65 return error_.c_str();
66 }
67
68private:
69 std::string error_;
70};
71
72#endif // _MyException_
Definition MyException.h:40
MyException(const std::string &errormessage)
Construct an exception using a C++-style string.
Definition MyException.h:49
const char * what() const
What's going on?
Definition MyException.h:59
MyException(const char *errormessage)
Construct an exception using a C-style character string.
Definition MyException.h:43
std::string error_
Definition MyException.h:69
virtual ~MyException()
Destroy.
Definition MyException.h:55