torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Error.cpp
Go to the documentation of this file.
1 // Torc - Copyright 2011-2013 University of Southern California. All Rights Reserved.
2 // $HeadURL$
3 // $Id$
4 
5 // This program is free software: you can redistribute it and/or modify it under the terms of the
6 // GNU General Public License as published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 // without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
11 // the GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License along with this program. If
14 // not, see <http://www.gnu.org/licenses/>.
15 
16 #ifndef HAVE_CONFIG_H
17 #include "torc/generic/config.h"
18 #endif
19 
20 #include "torc/generic/Error.hpp"
21 
22 namespace torc {
23 namespace generic {
24 
26  uint32_t inLine) : mFunction(inFunction), mFile(inFile), mLine(inLine) {}
27 
29 
31  mFunction(source.mFunction), mFile(source.mFile), mLine(source.mLine) {}
32 
34  if(this != &source) {
35  mFunction = source.mFunction;
36  mFile = source.mFile;
37  mLine = source.mLine;
38  }
39  return *this;
40 }
41 
42 Error::Error(MessageId inId, const Context& inContext, const std::string& inFunction,
43  const std::string& inFile, uint32_t inLine) : mStackTrace(), mContextData(inContext),
44  mErrorMessageId(inId) {
45  StackFrameInfo info(inFunction, inFile, inLine);
46  mStackTrace.push_back(info);
47 }
48 
49 /**
50  * @overload
51  */
52 Error::Error(MessageId inId, const std::string& inFunction, const std::string& inFile,
53  uint32_t inLine) :
54  mStackTrace(), mContextData(), mErrorMessageId(inId) {
55  StackFrameInfo info(inFunction, inFile, inLine);
56  mStackTrace.push_back(info);
57 }
58 
59 Error::~Error() throw () {}
60 
61 Error::Error(const Error& source) : mStackTrace(source.mStackTrace),
62  mContextData(source.mContextData), mErrorMessageId(source.mErrorMessageId) {}
63 
64 Error& Error::operator=(const Error& source) {
65  if(this != &source) {
66  mStackTrace = source.mStackTrace;
67  mContextData = source.mContextData;
69  }
70  return *this;
71 }
72 
73 void Error::setCurrentLocation(const std::string& inFunction, const std::string& inFile,
74  uint32_t inLine) {
75  StackFrameInfo info(inFunction, inFile, inLine);
76  mStackTrace.push_back(info);
77 }
78 
79 void Error::saveContextData(const std::string& inName, const boost::any& inSource) {
80  mContextData[inName] = inSource;
81 }
82 
83 } // namespace generic
84 } // namespace torc
Error & operator=(const Error &source)
Definition: Error.cpp:64
Error(MessageId inId, const Context &inContext, const std::string &inFunction, const std::string &inFile, uint32_t inLine)
Definition: Error.cpp:42
MessageId mErrorMessageId
Definition: Error.hpp:155
std::string string
std::map< std::string, boost::any > Context
Definition: Error.hpp:48
The Error object thrown by different methods of EdifOM.
Definition: Error.hpp:41
Context mContextData
Definition: Error.hpp:154
void saveContextData(const std::string &inName, const boost::any &inSource)
Definition: Error.cpp:79
StackFrameInfo(const std::string &inFunction, const std::string &inFile, uint32_t inLine)
Definition: Error.cpp:25
StackFrameInfo & operator=(const StackFrameInfo &source)
Definition: Error.cpp:33
std::vector< StackFrameInfo > mStackTrace
Definition: Error.hpp:153
void setCurrentLocation(const std::string &inFunction, const std::string &inFile, uint32_t inLine)
Definition: Error.cpp:73