ROOT_Application  2.0
C++ Core modules and GUIStock
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UtilsExceptions.cpp
Go to the documentation of this file.
1 
8 #include "UtilsExceptions.h"
9 
10 // use utils for getting line number, but could not specific to this project
11 #include "Utils.h"
12 
14 FileOpenError::FileOpenError( const std::string & fileNameIn ) :
15  FileError( fileNameIn )
16 {
17 #ifdef DEBUG_EXCEPT
18  std::cout << "Constructor FileOpenError 1 string argument fileNameIn " << fileNameIn << std::endl;
19 #endif
20  mFileMsg = "FileOpenError : Unable to open " + fileNameIn +"\n";
21 }
22 
24 FileEmptyError::FileEmptyError( const std::string & fileNameIn ) :
25  FileError( fileNameIn )
26 {
27  mFileMsg = "FileEmptyError : File is empty " + fileNameIn+"\n";
28 }
29 
30 // line number is optional. set to -1 by default */
31 FileReadError::FileReadError(const std::string& fileNameIn, int lineNumIn)
32 : FileError(fileNameIn), mLineNum(lineNumIn)
33 {
34  mFileMsg = "FileReadError in reading data in " + fileNameIn ;
35  if ( mLineNum != -1 ) {
36  mFileMsg += "at line: " + Utils::toString(mLineNum);
37  }
38  mFileMsg +="\n";
39 }
40 // assign a specific message
41 FileReadError::FileReadError(const std::string& fileNameIn, const std::string& msg)
42 : FileError(fileNameIn), mLineNum(-1)
43 {
44  mFileMsg = "FileReadError in reading data in " + fileNameIn + " ";
45  /*
46  if ( mLineNum != -1 ) {
47  mFileMsg += "at line: " + Utils::toString(mLineNum);
48  }*/
49  mFileMsg += "\n" + msg;
50  mFileMsg +="\n";
51 }
Define general exception, of general utility.
Base class for error handling with files.
Group general functions to convert to/from string, split line...
std::string toString(const T &t)
Definition: Utils.h:69
FileReadError(const std::string &fileNameIn, int lineNumIn=-1)
std::string mFileMsg
FileEmptyError(const std::string &fileNameIn)
if empty eally or empty of data
FileOpenError(const std::string &fileNameIn)
Modify the message do make it explicit.