ViennaSHE 1.3.0
Free open-source semiconductor device simulator using spherical harmonics expansions techniques.
exception.hpp
Go to the documentation of this file.
1#ifndef VIENNASHE_MODELS_MARKOVCHAIN_EXCEPTION_HPP
2#define VIENNASHE_MODELS_MARKOVCHAIN_EXCEPTION_HPP
3/* ============================================================================
4 Copyright (c) 2011-2022, Institute for Microelectronics,
5 Institute for Analysis and Scientific Computing,
6 TU Wien.
7
8 -----------------
9 ViennaSHE - The Vienna Spherical Harmonics Expansion Boltzmann Solver
10 -----------------
11
12 http://viennashe.sourceforge.net/
13
14 License: MIT (X11), see file LICENSE in the base directory
15=============================================================================== */
16
17#include <stdexcept>
18#include <sstream>
20
21
26namespace viennashe
27{
28 namespace models
29 {
30
32 class invalid_state_exception : public std::runtime_error
33 {
34 public:
35 invalid_state_exception(std::string const & str)
36 : std::runtime_error(str), msg_(""), index_(0), msgcache_("") { }
37
38 virtual const char* what() const throw() { return this->msgcache_.c_str(); }
39
40 invalid_state_exception(std::string msg, std::size_t index)
41 : std::runtime_error(msg), msg_(msg), index_(index)
42 { this->fill_message(); }
43
44 virtual ~invalid_state_exception() throw() {}
45
46 private:
47
48 void fill_message()
49 {
50 std::stringstream ss;
51 ss << "* Models: invalid state '" << index_ << "' does not exist or is malconfigured, i.e. state.occupancy() > 1.0 or state.occupancy() < 0 !";
52 ss << " Message: '" << msg_ << "'";
53 this->msgcache_ = ss.str();
54 }
55
56 std::string msg_;
57 std::size_t index_;
58 std::string msgcache_;
59 };
60
61 } // namespace models
62} // namespace viennashe
63
64#endif /* VIENNASHE_MODELS_MARKOVCHAIN_EXCEPTION_HPP */
65
Thrown whenever a markov chain model finds an invalid or non-existing state.
Definition: exception.hpp:33
invalid_state_exception(std::string const &str)
Definition: exception.hpp:35
invalid_state_exception(std::string msg, std::size_t index)
Definition: exception.hpp:40
virtual const char * what() const
Definition: exception.hpp:38
Contains exceptions for viennashe::models.
The main ViennaSHE namespace. All functionality resides inside this namespace.
Definition: accessors.hpp:40