exception_t.h 2.19 KB
/**
 * \file    scot/exception_t.h
 * \author  Georg Steffers <georg@steffers.org>
 * \brief   The datatypes for exceptions.
 *
 * Copyright (C)2006    Georg Steffers <georg@steffers.org>
 * 
 * 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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */
#ifndef  STACK_EXCEPTION_T_H
#define  STACK_EXCEPTION_T_H

/**
 * \brief give the two states a speaking name.
 *
 * There are two exceptions possible EXC_ERRORS, that immediatly abort the
 * current operation and EXC_WARNINGS, that will just be mentioned within
 * the exception stack.
 */
enum exclvl_t {EXC_WARNING, EXC_ERROR};

struct exception_t;
typedef struct exception_t exception_t;

#ifndef  USE_SCOT_STRUCT_EXCEPTION_T
struct exception_t
{
   const char _ [sizeof (struct {
               int            was_catched;
         const enum exclvl_t  lvl;
         const char           *file;
         const int            line;
         const int            errnum;
         const char           *err_msg;
         })];
};
#else
/**
 * \internal
 * \brief holds an exception.
 */
struct exception_t
{
         int            was_catched; /**< how often was it catched */
   const enum exclvl_t  lvl;         /**< EXC_ERROR or EXC_WARNING */
   const char           *file;       /**< file where it was created */
   const int            line;        /**< line of that file */
   const int            errnum;      /**< number of the error */
   const char           *err_msg;    /**< message of the error */
};

#include <scot/queue_type_proto.h>
GEN_QUEUE_TYPE_PROTO (exception_t);
#endif

#endif   /* STACK_EXCEPTION_T_H */