Skip to content

Commit

Permalink
Frame exception fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Kornel Kisielewicz committed Aug 11, 2010
1 parent 3e51473 commit 7d004be
Show file tree
Hide file tree
Showing 2 changed files with 125 additions and 0 deletions.
45 changes: 45 additions & 0 deletions tpserver/server/frameexception.cpp
@@ -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(){
}

80 changes: 80 additions & 0 deletions tpserver/server/frameexception.h
@@ -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

0 comments on commit 7d004be

Please sign in to comment.