SysCallExcn.cpp

Go to the documentation of this file.
00001 /*
00002 // $Id: //open/dev/fennel/common/SysCallExcn.cpp#13 $
00003 // Fennel is a library of data storage and processing components.
00004 // Copyright (C) 2005-2009 The Eigenbase Project
00005 // Copyright (C) 2005-2009 SQLstream, Inc.
00006 // Copyright (C) 2005-2009 LucidEra, Inc.
00007 // Portions Copyright (C) 1999-2009 John V. Sichi
00008 //
00009 // This program is free software; you can redistribute it and/or modify it
00010 // under the terms of the GNU General Public License as published by the Free
00011 // Software Foundation; either version 2 of the License, or (at your option)
00012 // any later version approved by The Eigenbase Project.
00013 //
00014 // This program is distributed in the hope that it will be useful,
00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 // GNU General Public License for more details.
00018 //
00019 // You should have received a copy of the GNU General Public License
00020 // along with this program; if not, write to the Free Software
00021 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022 */
00023 
00024 #include "fennel/common/CommonPreamble.h"
00025 #include "fennel/common/SysCallExcn.h"
00026 #include "fennel/common/FennelResource.h"
00027 #include <errno.h>
00028 #include <sstream>
00029 
00030 #ifdef __MSVC__
00031 #include <windows.h>
00032 #endif
00033 
00034 FENNEL_BEGIN_CPPFILE("$Id: //open/dev/fennel/common/SysCallExcn.cpp#13 $");
00035 
00036 SysCallExcn::SysCallExcn(std::string msgInit)
00037     : FennelExcn(msgInit), errCode(getCurrentErrorCode())
00038 {
00039     init();
00040 }
00041 
00042 SysCallExcn::SysCallExcn(std::string msgInit, int errCodeInit)
00043     : FennelExcn(msgInit), errCode(errCodeInit)
00044 {
00045     init();
00046 }
00047 
00048 void SysCallExcn::init()
00049 {
00050     std::ostringstream oss;
00051     oss << msg;
00052     oss << ": ";
00053 
00054 #ifdef __MSVC__
00055     oss << "GetLastError() = ";
00056     oss << errCode;
00057 #else
00058     char *pMsg = strerror(errCode);
00059     if (pMsg) {
00060         oss << pMsg;
00061     } else {
00062         oss << "errno = ";
00063         oss << errCode;
00064     }
00065 #endif
00066     msg = oss.str();
00067     msg = FennelResource::instance().sysCallFailed(msg);
00068 }
00069 
00070 
00071 int SysCallExcn::getErrorCode()
00072 {
00073     return errCode;
00074 }
00075 
00076 int SysCallExcn::getCurrentErrorCode()
00077 {
00078 #ifdef __MING32__
00079     return GetLastError();
00080 #else
00081     return errno;
00082 #endif
00083 }
00084 
00085 FENNEL_END_CPPFILE("$Id: //open/dev/fennel/common/SysCallExcn.cpp#13 $");
00086 
00087 // End SysCallExcn.cpp

Generated on Mon Jun 22 04:00:18 2009 for Fennel by  doxygen 1.5.1