2005-01-27 03:35:23 +00:00
|
|
|
//This file is part of Photon (http://photon.sourceforge.net)
|
|
|
|
//Copyright (C) 2004-2005 James Turk
|
|
|
|
//
|
|
|
|
// Author:
|
|
|
|
// James Turk (jpt2433@rit.edu)
|
|
|
|
//
|
|
|
|
// Version:
|
2005-02-27 05:51:59 +00:00
|
|
|
// $Id: exceptions.cpp,v 1.6 2005/02/27 05:52:00 cozman Exp $
|
2005-01-27 03:35:23 +00:00
|
|
|
|
|
|
|
|
2005-02-13 22:12:02 +00:00
|
|
|
#include "exceptions.hpp"
|
2005-01-27 03:35:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace photon
|
|
|
|
{
|
|
|
|
|
2005-02-07 01:48:25 +00:00
|
|
|
Throwable::Throwable(const std::string& description,
|
|
|
|
const std::string& file, uint line) throw() :
|
2005-01-31 15:44:38 +00:00
|
|
|
description_(description), file_(file), line_(line)
|
|
|
|
{}
|
|
|
|
|
|
|
|
Throwable::~Throwable() throw()
|
|
|
|
{}
|
|
|
|
|
2005-02-27 05:51:59 +00:00
|
|
|
std::string Throwable::what() const throw()
|
2005-01-27 03:35:23 +00:00
|
|
|
{
|
2005-01-31 15:44:38 +00:00
|
|
|
std::ostringstream ss;
|
|
|
|
|
|
|
|
ss << description_;
|
|
|
|
if(!file_.empty())
|
|
|
|
{
|
|
|
|
ss << " (" << file_ << ":" << line_ << ")";
|
|
|
|
}
|
|
|
|
return ss.str();
|
2005-01-27 03:35:23 +00:00
|
|
|
}
|
|
|
|
|
2005-02-27 05:51:59 +00:00
|
|
|
std::ostream& operator<<(std::ostream& os, const Throwable& rhs)
|
|
|
|
{
|
|
|
|
return os << rhs.what();
|
|
|
|
}
|
|
|
|
|
2005-01-27 03:35:23 +00:00
|
|
|
//exceptions//
|
|
|
|
|
2005-02-07 01:48:25 +00:00
|
|
|
Exception::Exception(const std::string& description,
|
|
|
|
const std::string& file, uint line) throw() :
|
2005-01-31 15:44:38 +00:00
|
|
|
Throwable(description,file,line) {}
|
2005-02-27 05:51:59 +00:00
|
|
|
std::string Exception::what() const throw()
|
2005-01-27 03:35:23 +00:00
|
|
|
{
|
2005-02-27 05:51:59 +00:00
|
|
|
return "General exception occured: " + Throwable::what();
|
2005-01-27 03:35:23 +00:00
|
|
|
}
|
|
|
|
|
2005-02-07 01:48:25 +00:00
|
|
|
ArgumentException::ArgumentException(const std::string& description,
|
|
|
|
const std::string& file, uint line) throw() :
|
2005-01-31 15:44:38 +00:00
|
|
|
Exception(description,file,line) {}
|
2005-02-27 05:51:59 +00:00
|
|
|
std::string ArgumentException::what() const throw()
|
2005-01-27 03:35:23 +00:00
|
|
|
{
|
2005-02-27 05:51:59 +00:00
|
|
|
return "Invalid argument exception occured: " + Throwable::what();
|
2005-01-27 03:35:23 +00:00
|
|
|
}
|
|
|
|
|
2005-02-07 01:48:25 +00:00
|
|
|
PreconditionException::PreconditionException(const std::string& description,
|
|
|
|
const std::string& file, uint line) throw() :
|
2005-01-31 15:44:38 +00:00
|
|
|
Exception(description,file,line) {}
|
2005-02-27 05:51:59 +00:00
|
|
|
std::string PreconditionException::what() const throw()
|
2005-01-27 03:35:23 +00:00
|
|
|
{
|
2005-02-27 05:51:59 +00:00
|
|
|
return "Precondition exception occured: " + Throwable::what();
|
2005-01-27 03:35:23 +00:00
|
|
|
}
|
|
|
|
|
2005-02-07 01:48:25 +00:00
|
|
|
RangeException::RangeException(const std::string& description,
|
|
|
|
const std::string& file, uint line) throw() :
|
2005-01-31 15:44:38 +00:00
|
|
|
Exception(description,file,line) {}
|
2005-02-27 05:51:59 +00:00
|
|
|
std::string RangeException::what() const throw()
|
2005-01-27 03:35:23 +00:00
|
|
|
{
|
2005-02-27 05:51:59 +00:00
|
|
|
return "Out-of-range exception: " + Throwable::what();
|
2005-01-27 03:35:23 +00:00
|
|
|
}
|
|
|
|
|
2005-02-07 01:48:25 +00:00
|
|
|
ResourceException::ResourceException(const std::string& description,
|
|
|
|
const std::string& file, uint line) throw() :
|
2005-01-31 15:44:38 +00:00
|
|
|
Exception(description,file,line) {}
|
2005-02-27 05:51:59 +00:00
|
|
|
std::string ResourceException::what() const throw()
|
2005-01-27 03:35:23 +00:00
|
|
|
{
|
2005-02-27 05:51:59 +00:00
|
|
|
return "Resource exception: " + Throwable::what();
|
2005-01-27 03:35:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//errors//
|
|
|
|
|
2005-02-07 01:48:25 +00:00
|
|
|
Error::Error(const std::string& description,
|
|
|
|
const std::string& file, uint line) throw() :
|
2005-01-31 15:44:38 +00:00
|
|
|
Throwable(description,file,line) {}
|
2005-02-27 05:51:59 +00:00
|
|
|
std::string Error::what() const throw()
|
2005-01-27 03:35:23 +00:00
|
|
|
{
|
2005-02-27 05:51:59 +00:00
|
|
|
return "General error occured: " + Throwable::what();
|
2005-01-27 03:35:23 +00:00
|
|
|
}
|
|
|
|
|
2005-02-07 01:48:25 +00:00
|
|
|
MemoryError::MemoryError(const std::string& description,
|
|
|
|
const std::string& file, uint line) throw() :
|
2005-01-31 15:44:38 +00:00
|
|
|
Error(description,file,line) {}
|
2005-02-27 05:51:59 +00:00
|
|
|
std::string MemoryError::what() const throw()
|
2005-01-27 03:35:23 +00:00
|
|
|
{
|
2005-02-27 05:51:59 +00:00
|
|
|
return "Memory error occured: " + Throwable::what();
|
2005-01-27 03:35:23 +00:00
|
|
|
}
|
|
|
|
|
2005-02-07 01:48:25 +00:00
|
|
|
APIError::APIError(const std::string& description,
|
|
|
|
const std::string& file, uint line) throw() :
|
2005-01-31 15:44:38 +00:00
|
|
|
Error(description,file,line) {}
|
2005-02-27 05:51:59 +00:00
|
|
|
std::string APIError::what() const throw()
|
2005-01-27 03:35:23 +00:00
|
|
|
{
|
2005-02-27 05:51:59 +00:00
|
|
|
return "Error occured within another library: " + Throwable::what();
|
2005-01-27 03:35:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|