ROOT_Application  2.0
C++ Core modules and GUIStock
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
StockException.h
Go to the documentation of this file.
1 
15 #ifndef STOCKEXCEPT_H_
16 #define STOCKEXCEPT_H_
17 
18 #include<string>
19 #include<stdexcept>
20 #include<iostream>
21 
22 // all cases need only Exceptions header
23 #include "../utils/UtilsExceptions.h"
24 #include "TALibException.h"
25 
44 class StockException : public std::exception
45 {
46  public :
47  // not used but may be useful
48  StockException() : std::exception(), mNameStock(), mTimescale(), mIndic(), mStockMsg() {
49 #ifdef DEBUG_EXCEPT
50  std::cout << "Constructor StockException Base with no argument " << std::endl;
51 #endif
52  }
53  // here use the message of the caller simply
54  StockException( const std::string & namestock );
55  // only make an error
56  StockException( const std::string & namestock, const std::string & message )
57  : std::exception(), mNameStock(namestock), mTimescale(), mIndic(), mStockMsg(message) {}
58  StockException( const std::string & namestock, const std::string & tmscl, const std::string & indicator );
59 
60  // could get 2 parameters, already useful, same purpose specify the error message
61  //StockException( const std::string &stockname, const std::string &mMsg, const std::string &indic_label = std::string() );
62  // could get the exception / and try to dynamic_cast to create the final message
63 
64  ~StockException() throw() {}
66  std::string GetMessage() const {return mStockMsg;}
67  void AddHeaderMessage();
68  virtual const char * what() const noexcept {
69  // if composition, may want to return the protected mExcept.what()
70  return mStockMsg.c_str();
71  }
72  //virtual const char * what() const noexcept = 0;
73 
74  // could have specific getnamestock() in base class
75  // shared by all derivatives, can set directly or constructor base
76  protected :
78  std::string mNameStock;
79  std::string mTimescale;
80  std::string mIndic;
82  std::string mStockMsg;
83  // optionally the indicator which makes crash for TALib mainly but not only
84  // better if in specialized, but general which indicator crashes
85  //ETime mTimescale;
86 
87 };
88 
95 // if use multiple derivation, public virtual seems to work, not sure how ??
96 // maybe only one public derivative
97 class StockFileError : public virtual StockException, public virtual FileError
98 {
99  public :
100 
102  StockFileError ( const std::string & namestock, const FileError & fError );
103  StockFileError ( const std::string & namestock, const std::string & tmscl,
104  const std::string & indic_label, const FileError & fError );
105 
106  // call to e.what is ambiguous, defined in both base class
107  // yes it is need to include, at least for debug
108  virtual const char * what() const noexcept {
109  //std::cout << "Ambiguous what is overriden in StockFileError " << std::endl;
110  return StockException::what();
111  }
112 };
113 
119 // either a derivative for TALib or a composition...
120 // a sort of base class for TAlib error
121 class StockTALibError : public virtual StockException, public virtual TALibException
122 {
123  public :
124  // not used
125  StockTALibError ( const TALibException & fError ) :
127  std::cout << "Constructor StockTALibError " << std::endl;
128  mStockMsg = fError.what();
129  }
130  StockTALibError ( const std::string & namestock, const std::string & tmscl, const TALibException & fError );
131  virtual const char * what() const noexcept {
132  return StockException::what();
133  }
134 };
135 
144 {
145  public :
146  StockPythonException ( const std::string & namestock, const std::string & message ) :
147  StockException ( namestock ) {
148  mStockMsg = "Stock : " + namestock + "\nPythonError : " + message;
149  }
150  virtual const char * what() const noexcept {
151  return StockException::what();
152  }
153 };
154 
155 #endif //STOCKEXCEPT_H_
StockFileError(const std::string &namestock, const FileError &fError)
similar, best alternative can be build with any FileError derivative
Specific, inherit from FileError from utils.
virtual const char * what() const noexcept
virtual const char * what() const noexcept
std::string mStockMsg
used by base class
StockPythonException(const std::string &namestock, const std::string &message)
Base class for error handling with files.
Base Exception for Stock and StockManager, all src_cpp code.
virtual const char * what() const noexcept
for getting the message with standard interface do not throw exception
std::string mTimescale
void AddHeaderMessage()
indic_label is optional
Specific for TALib part of the code.
Centralize all exception coming form the TALib library interface.
virtual const char * what() const noexcept
virtual const char * what() const noexcept
std::string GetMessage() const
allow GUIException to get the message
Base class for exception coming from talibapi interface.
Specific the wrapper python.
std::string mNameStock
general enought to be in base class
StockTALibError(const TALibException &fError)
std::string mIndic
StockException(const std::string &namestock, const std::string &message)