Staging
v0.5.1
rsync://a.cvs.sourceforge.net/cvsroot/titano/titano
Raw File
Tip revision: caf6b08e7ee50ea57b401dbf73c67715c80ad881 authored by amid on 31 January 2001, 05:11:03 UTC
*** empty log message ***
Tip revision: caf6b08
iexceptions.h
/* iexceptions.h - Internal Titano exceptions -*- C++ -*-
 * Copyright (C) 2000 Malenko Dmitry <maldim@mail.ru>
 *
 * 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, 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.  
 */

#ifndef _IEXCEPTIONS_H
#define _IEXCEPTIONS_H

#include <exception>
#include <string>
#include <string.h>

class Exception : public exception
{
protected:
	string message;
public:
	Exception(const string &msg = "Unknown error.") :
		message(msg)
	{ };
	
	virtual operator string()
	{
		return message;
	};
};

class EIOError : public Exception
{
protected:
	string filename;
	int error;
public:
	EIOError(const string &msg = "Unknown I/O error.",const string &file = "",const int err = -1) :
		Exception(msg),
		filename(file),
		error(err)
	{ };

	virtual operator string()
	{
		return message + "\n" +
			"    File: " + filename + "\n" +
			"    Error: " + strerror(error);
	};
};

class ENotSupported : public Exception
{
protected:
	string oper;
	string reason;
public:
	ENotSupported(const string &op = "Unknown",const string &reas = "Unknown") :
		Exception("Operation not supported."),
		oper(op),
		reason(reas)
	{ };

	virtual operator string()
	{
		return message + "\n" +
			"    Operation: " + oper + "\n" +
			"    Reason: " + reason + "\n";
	};
};

class EShellError : public Exception
{
protected:
	string cmd;
	int error;
public:
	EShellError(const string &_cmd = "Unknown",const int err = 0) :
		Exception("Shell command execution failed."),
		cmd(_cmd),
		error(err)
	{ };

	virtual operator string()
	{
		return message + "\n" +
			"    Command: " + cmd + "\n" + 
			"    Error: " + (error==127?"Shell not found.":strerror(error));
	};
};

#endif
back to top