/*
 * The UDS collection
 * Copyright (C) 1999, 2000, 2001  Julian v. Bock
 *
 * 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
 *
 *	(See file COPYING for more information)
 */

#ifndef _uds_stdexcpt_hh
#define _uds_stdexcpt_hh


// includes

#include <uds/errnodiag.hh>
#include <uds/exception.hh>


namespace uds
{

// standard exceptions

/// thrown when an internal error occurs
_uds_ExceptionClassF( internal_error, Exception, "internal error", NoDiag, true );
/// thrown when a zombie object is encountered
_uds_ExceptionClassF( zombie_object, Exception, "zombie object invoked", NoDiag, true );

/// thrown when a system function fails
_uds_ExceptionClass( system_error, Exception, "system error", ErrnoDiag );
/// thrown when a file can not be accessed
_uds_ExceptionClass( file_error, system_error, "file error", ErrnoDiag );
/// thrown an operation on a pipe fails
_uds_ExceptionClass( pipe_error, system_error, "pipe error", ErrnoDiag );
/// thrown when a call to fork() fails
_uds_ExceptionClass( fork_error, system_error, "unable to fork", ErrnoDiag );
/// thrown when a programm can not be executed
_uds_ExceptionClass( exec_error, system_error, "unable to execute program", ErrnoDiag );
/// thrown when a child process didn't exit successfully
_uds_ExceptionClass( child_error, system_error, "child process failed", NoDiag );

/// thrown when a logic error occurs
_uds_ExceptionClass( logic_error, Exception, "logic error", NoDiag );
/// thrown when a function is called in an invalid environment
_uds_ExceptionClass( bad_call, logic_error, "bad function call", NoDiag );
/// thrown when an invalid argument is passed to a function
_uds_ExceptionClass( invalid_arg, bad_call, "invalid function argument", NoDiag );

/// thrown when a runtime error occurs
_uds_ExceptionClass( runtime_error, Exception, "runtime error", NoDiag );
/// thrown when a bad command line option is passed to the program
_uds_ExceptionClass( bad_cmd_line_opt, runtime_error, "bad command line option", NoDiag );
/// generic error exception for friendly program termination
_uds_ExceptionClassF( error, runtime_error, "error", NoDiag, false );


/** This macro throws an internal_error exception with the source location */
#define _uds_abort                                                           \
	throw uds::internal_error( _uds_SourceLocation )
}

#endif // _uds_stdexcpt_hh
