CS 280 - Programming Assignment #1


Information

Other Criteria

Exception Handling Examples

Please note that these are examples! Your code will probably be different.


  // Make sure this object hasn't been freed yet
if (is_on_freelist(anObject))
  throw OAException(OAException::E_MULTIPLE_FREE, "FreeObject: Object has already been freed.");


  // If new throws an exception, catch it, and throw our own type of exception
char *newpage;
try
{
  newpage = new char[PageSize_];
}
catch (std::bad_alloc &)
{
  throw OAException(OAException::E_NO_MEMORY, "allocate_new_page: No system memory available.");
}
if ( /* Object is on a valid page boundary */ )
  // put it on the free list
else
  throw OAException(OAException::E_BAD_BOUNDARY, "validate_object: Object not on a boundary.");


Download the GUI executable This is an older version (doesn't include all of the header block functionality) that includes the more sophisticated "hex viewer" component on the Page list tab.