/*
 *
 *    exception.h
 *
 *    Home for my::exception_template for use in making useful exceptions
 *    for use in my++ classes.
 *
 *    =========================================================================
 *
 *    Copyright (C) 2001-2003 by Matt Roberts, KK5JY.
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License as published by the Free Software Foundation; either
 *    version 2.1 of the License, or (at your option) any later version.
 *
 *    This library 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
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 *    =========================================================================
 *
 *
 */

#ifndef __MY_EXCEPTION_H
#define __MY_EXCEPTION_H

#include <exception>
#include <string>
#include <cstring>

	namespace my {

		/*
		 *
		 *   [generic] class exception_template
		 *
		 */

		template <class type>
			class exception_template : public std::exception {
				private:
					const int   tdet_errno;
					const type *tdet_object;
					const std::string tdet_what;

				public:
					exception_template (const type *obj, const int num)
						: tdet_errno(num), tdet_object(obj), tdet_what(strerror(num)) { };
					exception_template (const type *obj, const std::string &desc)
						: tdet_errno(0), tdet_object(obj), tdet_what(desc) { };
					~exception_template (void) throw() { /* noop */ };

					virtual const int   errnum (void) const throw() { return tdet_errno;  };
					virtual const type *object (void) const throw() { return tdet_object; };
					virtual const char *what   (void) const throw() { return tdet_what.c_str();  };
			};
	}

#endif /* __MY_EXCEPTION_H */

