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_EXCEPTION_HPP
2#define VIENNASHE_MODELS_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
18#include <stdexcept>
19#include <sstream>
20
26namespace viennashe
27{
28 namespace models
29 {
31 class invalid_parameter_exception : public std::runtime_error
32 {
33 public:
34 invalid_parameter_exception(std::string const & str)
35 : std::runtime_error(str), msg_(""), value_(0) { this->fill_message(); }
36
37 virtual const char* what() const throw() { return this->msgcache_.c_str(); }
38
39 invalid_parameter_exception(std::string msg, double value)
40 : std::runtime_error(msg), msg_(msg), value_(value) { this->fill_message(); }
41
42 virtual ~invalid_parameter_exception() throw() {}
43
44 private:
45
46 void fill_message()
47 {
48 std::stringstream ss;
49 ss << "* Models: Invalid parameter! '" << msg_ << "' Invalid value being: '" << value_ << "'";
50 msgcache_ = ss.str();
51 }
52
53 std::string msg_;
54 double value_;
55 std::string msgcache_;
56 };
57
59 class index_out_of_bounds_exception : public std::runtime_error
60 {
61 public:
62 index_out_of_bounds_exception(std::string const & str)
63 : std::runtime_error(str), msg_(""), index_(0), bound_(0), msgcache_("") { }
64
65 virtual const char* what() const throw() { return this->msgcache_.c_str(); }
66
67 index_out_of_bounds_exception(std::string msg, long index, long bound)
68 : std::runtime_error(msg), msg_(msg), index_(index), bound_(bound)
69 { this->fill_message(); }
70
71 virtual ~index_out_of_bounds_exception() throw() {}
72
73 private:
74
75 void fill_message()
76 {
77 std::stringstream ss;
78 ss << "* Models: index out of bounds! '" << msg_ << "' index being: '" << index_ << "'" << "' bound being: '" << bound_ << "'";
79 this->msgcache_ = ss.str();
80 }
81
82 std::string msg_;
83 long index_;
84 long bound_;
85 std::string msgcache_;
86 };
87
89 class model_evaluation_exception : public std::runtime_error {
90 public:
91 model_evaluation_exception(std::string const & str) : std::runtime_error(str) {}
92 };
93
94 } // namespace models
95
96} // namespace viennashe
97
98#endif /* VIENNASHE_MODELS_EXCEPTION_HPP */
99
Thrown whenever a model finds an index to be out of bounds.
Definition: exception.hpp:60
index_out_of_bounds_exception(std::string const &str)
Definition: exception.hpp:62
index_out_of_bounds_exception(std::string msg, long index, long bound)
Definition: exception.hpp:67
Thrown whenever an invalid parameter to a model is given.
Definition: exception.hpp:32
invalid_parameter_exception(std::string const &str)
Definition: exception.hpp:34
invalid_parameter_exception(std::string msg, double value)
Definition: exception.hpp:39
Exception for the case that the evaluation of a model fails.
Definition: exception.hpp:89
model_evaluation_exception(std::string const &str)
Definition: exception.hpp:91
The main ViennaSHE namespace. All functionality resides inside this namespace.
Definition: accessors.hpp:40