ROOT_Application  2.0
C++ Core modules and GUIStock
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
StockException.cpp
Go to the documentation of this file.
1 
8 #include "StockException.h"
9 
10 
11 // constructor, better to give the namestock in constructor
12 StockException::StockException( const std::string & namestock ) :
13  std::exception(), mNameStock( namestock ), mTimescale(), mStockMsg()
14 {
15 #ifdef DEBUG_EXCEPT
16  std::cout << "Constructor Base StockException with namestock " << mNameStock << std::endl;
17 #endif
18 }
19 
20 // not used yet
21 //StockException::StockException( const std::string & namestock, const ETime & tmscl, const std::string & indic_label ) :
22 StockException::StockException( const std::string & namestock, const std::string & tmscl, const std::string & indic_label ) :
23  std::exception(), mNameStock( namestock ), mTimescale ( tmscl ), mIndic( indic_label)
24 {
25 #ifdef DEBUG_EXCEPT
26  std::cout << "Constructor StockException with namestock, timescale, indicator " << mNameStock << std::endl;
27 #endif
28  //mStockMsg = "Stock: " + namestock +"\nTimeScale: " + mTimescale + "\nIndicator: " + mIndic;
30 }
31 
33 // not sure it is used
34 /*
35 StockException::StockException( const std::string &namestock, const std::string & mMsg, const std::string & indic_label ) :
36  std::exception(), mIndic ( indic_label ), mStockMsg( mMsg ), mTimescale ( ETime::DAY )
37 {
38 #ifdef DEBUG_EXCEPT
39  std::cout << "Constructor StockException 2/3 string arguments mStockMsg " << mStockMsg << std::endl;
40  std::cout << "namestock " << namestock << std::endl;
41 #endif
42  //mTimescale = ETime::DAY;
43  // create specific message here or available from GUIException
44  mStockMsg = "Stock: " + namestock + "\nError: " + mMsg;
45  std::cout << "Test better message \n" << mStockMsg << std::endl;
46 }
47 */
48 
50 {
51  // should test if setup data are valid
52  mStockMsg = "Stock: " + mNameStock +"\nTimeScale: " + mTimescale + "\nIndicator: " + mIndic +"\n";
53 }
54 
56 // used in Stock::ReadCSV, Indicator is missing but no parameter here
57 StockFileError::StockFileError ( const std::string & namestock, const FileError & fError ) :
58  StockException( namestock ), FileError( fError )
59 {
60 #ifdef DEBUG_EXCEPT
61  std::cout << "StockFileError constructor, namestock and FileError" << std::endl;
62  std::cout << "what() form FileError " << fError.what() << std::endl;
63 #endif
64  // create specific message here or available from GUIException
65  //mStockMsg = "StockFileError: " + namestock + "\n" + fError.what();
67  mStockMsg += fError.what();
68 }
69 
70 StockFileError::StockFileError ( const std::string & namestock, const std::string & tmscl,
71  const std::string & indic_label, const FileError & fError ) :
72  StockException( namestock, tmscl, indic_label ), FileError ( fError )
73 {
74 #ifdef DEBUG_EXCEPT
75  std::cout << "StockFileError constructor, namestock timescale indic and FileError" << std::endl;
76  std::cout << "what() form FileError " << fError.what() << std::endl;
77 #endif
78  // seems similar to set member or call constructor stock, design to decide
79  //mTimescale = tmscl;
80  //mIndic = Indicator::Null.label();
82  mStockMsg += fError.what();
83 }
84 
86 StockTALibError::StockTALibError ( const std::string & namestock, const std::string & tmscl, const TALibException & fError ) :
87  StockException( namestock ), TALibException( fError ) {
88 #ifdef DEBUG_EXCEPT
89  std::cout << "Constructor StockTALibError with namestock " << std::endl;
90 #endif
91  mTimescale = tmscl;
92  mIndic = fError.GetIndicator();
93  //mStockMsg = fError.what();
94  // here already preformatted message, namestock to add
95  //mStockMsg =
97  // could call a base function, insert on top of message name, time, indicator
98  mStockMsg += "StockTALibError:\n"; //\nNamestock: " + mNameStock + "\n";
99 
100  //mStockMsg += "Indicator: " + fError.GetIndicator() + "\n";
101  // Add the original message
102  mStockMsg += fError.what();
103 }
104 
105 
106 
107 
108 
109 
StockFileError(const std::string &namestock, const FileError &fError)
similar, best alternative can be build with any FileError derivative
std::string GetIndicator() const
std::string mStockMsg
used by base class
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
Exception to be used within stock_cpp.
virtual const char * what() const noexcept
Base class for exception coming from talibapi interface.
std::string mNameStock
general enought to be in base class
StockTALibError(const TALibException &fError)
std::string mIndic