BadgerDB
 All Classes Namespaces Functions Variables Typedefs Friends
Public Member Functions | Protected Attributes | Friends
badgerdb::InvalidPageException Class Reference

An exception that is thrown when an attempt is made to access an invalid page in a file. More...

#include <invalid_page_exception.h>

Inheritance diagram for badgerdb::InvalidPageException:
badgerdb::BadgerDbException

List of all members.

Public Member Functions

 InvalidPageException (const PageId requested_number, const std::string &file)
virtual ~InvalidPageException () throw ()
virtual PageId page_number () const
virtual const std::string & filename () const
virtual const std::string & message () const
virtual const char * what () const throw ()

Protected Attributes

const PageId page_number_
const std::string filename_
std::string message_

Friends

std::ostream & operator<< (std::ostream &out, const BadgerDbException &exception)

Detailed Description

An exception that is thrown when an attempt is made to access an invalid page in a file.

Pages are considered invalid if they have not yet been allocated (an ID off the end of the file) or if they have been deleted and not yet re-allocated.

Definition at line 24 of file invalid_page_exception.h.


Constructor & Destructor Documentation

badgerdb::InvalidPageException::InvalidPageException ( const PageId  requested_number,
const std::string &  file 
)

Constructs an invalid page exception for the given requested page number and filename.

Parameters:
requested_numberRequested page number.
fileName of file that request was made to.

Definition at line 15 of file invalid_page_exception.cpp.

    : BadgerDbException(""),
      page_number_(requested_number),
      filename_(file) {
  std::stringstream ss;
  ss << "Request made for an invalid page."
     << " Requested page " << page_number_
     << " from file '" << filename_ << "'";
  message_.assign(ss.str());
}
virtual badgerdb::InvalidPageException::~InvalidPageException ( ) throw () [inline, virtual]

Destroys the exception. Does nothing special; just included to make the compiler happy.

Definition at line 40 of file invalid_page_exception.h.

{}

Member Function Documentation

virtual const std::string& badgerdb::InvalidPageException::filename ( ) const [inline, virtual]

Returns name of the file that caused this exception.

Definition at line 50 of file invalid_page_exception.h.

{ return filename_; }
virtual const std::string& badgerdb::BadgerDbException::message ( ) const [inline, virtual, inherited]

Returns a message describing the problem that caused this exception.

Returns:
Message describing the problem that caused this exception.

Definition at line 38 of file badgerdb_exception.h.

{ return message_; }
virtual PageId badgerdb::InvalidPageException::page_number ( ) const [inline, virtual]

Returns the requested page number that caused this exception.

Definition at line 45 of file invalid_page_exception.h.

{ return page_number_; }
virtual const char* badgerdb::BadgerDbException::what ( ) const throw () [inline, virtual, inherited]

Returns a description of the exception.

Returns:
Description of the exception.

Definition at line 45 of file badgerdb_exception.h.

{ return message_.c_str(); }

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  out,
const BadgerDbException exception 
) [friend, inherited]

Formats this exception for printing on the given stream.

Parameters:
outStream to print exception to.
exceptionException to print.
Returns:
Stream with exception printed.

Definition at line 54 of file badgerdb_exception.h.

                                                                      {
    out << exception.message();
    return out;
  }

Member Data Documentation

const std::string badgerdb::InvalidPageException::filename_ [protected]

Name of file which caused this exception.

Definition at line 61 of file invalid_page_exception.h.

std::string badgerdb::BadgerDbException::message_ [protected, inherited]

Message describing the problem that caused this exception.

Definition at line 64 of file badgerdb_exception.h.

Requested page number which caused this exception.

Definition at line 56 of file invalid_page_exception.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Functions Variables Typedefs Friends