forked from thousandparsec/tpserver-cpp
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Kornel Kisielewicz
committed
Aug 11, 2010
1 parent
3e51473
commit 7d004be
Showing
2 changed files
with
125 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* Frame Exception class | ||
* | ||
* Copyright (C) 2010 Lee Begg and the Thousand Parsec Project | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
* | ||
*/ | ||
|
||
|
||
#include "frameexception.h" | ||
|
||
FrameException::FrameException( FrameErrorCode code, const std::string& arg, const RefList& reflist ) : error_code(code), error_message(arg), error_reflist(reflist){ | ||
} | ||
|
||
const char* FrameException::what() const throw(){ | ||
return error_message.c_str(); | ||
} | ||
|
||
FrameErrorCode FrameException::getErrorCode() const{ | ||
return error_code; | ||
} | ||
|
||
const std::string& FrameException::getErrorMessage() const{ | ||
return error_message; | ||
} | ||
|
||
const RefList& FrameException::getRefList() const{ | ||
return error_reflist; | ||
} | ||
|
||
FrameException::~FrameException() throw(){ | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#ifndef FRAMEEXCEPTION_H | ||
#define FRAMEEXCEPTION_H | ||
/* Frame Exception class | ||
* | ||
* Copyright (C) 2009 Kornel Kisielewicz and the Thousand Parsec Project | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
* | ||
*/ | ||
|
||
#include <exception> | ||
#include <string> | ||
#include <tpserver/server/protocol.h> | ||
#include <tpserver/server/common.h> | ||
|
||
/** | ||
* Frame exception class | ||
* | ||
* Except for storing the error string that is later to be sent as a reply | ||
* it also stores the error code. | ||
*/ | ||
class FrameException : public std::exception { | ||
public: | ||
/** | ||
* Creation of exception | ||
* | ||
* @param code Frame error code as per protocol.h | ||
* @param arg Optional error string | ||
*/ | ||
|
||
explicit FrameException( FrameErrorCode code, const std::string& arg = "", const RefList& reflist = RefList() ); | ||
|
||
/** | ||
* Standard what() method, returns formated error message with | ||
* descriptive error_code definition. | ||
*/ | ||
virtual const char* what() const throw(); | ||
/** | ||
* Returns error code | ||
*/ | ||
FrameErrorCode getErrorCode() const; | ||
/** | ||
* Returns error message only | ||
*/ | ||
const std::string& getErrorMessage() const; | ||
|
||
/** | ||
* Returns RefList | ||
*/ | ||
const RefList& getRefList() const; | ||
|
||
/** | ||
* Standard destructor, does nothing. | ||
*/ | ||
virtual ~FrameException() throw(); | ||
|
||
private: | ||
/// Stored error code | ||
FrameErrorCode error_code; | ||
|
||
/// Stored error message | ||
std::string error_message; | ||
|
||
/// Stored RefList | ||
RefList error_reflist; | ||
}; | ||
|
||
#endif |