Main Page | Data Structures | File List | Data Fields | Globals

etl_error.h

Go to the documentation of this file.
00001 /* Copyright 2006 Garrett Rooney.
00002  *
00003  * Licensed under the Apache License, Version 2.0 (the "License");
00004  * you may not use this file except in compliance with the License.
00005  * You may obtain a copy of the License at
00006  *
00007  *     http://www.apache.org/licenses/LICENSE-2.0
00008  *
00009  * Unless required by applicable law or agreed to in writing, software
00010  * distributed under the License is distributed on an "AS IS" BASIS,
00011  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00012  * See the License for the specific language governing permissions and
00013  * limitations under the License.
00014  */
00015 
00016 /**
00017  * @file etl_error.h
00018  * @brief Functions for manipulating ETL exception objects
00019  */
00020 
00021 #ifndef ETL_ERROR_H
00022 #define ETL_ERROR_H
00023 
00024 #include <apr.h>
00025 #include <apr_errno.h>
00026 #include <apr_pools.h>
00027 
00028 #ifdef __cplusplus
00029 extern "C" {
00030 #endif /* __cplusplus */
00031 
00032 /**
00033  * Check if the @c etl_error_t returned by @a expression is equal to
00034  * @c ETL_SUCCESS.  If it is, do nothing, if not, then return it.
00035  */
00036 #define ETL_ERR(expression) do {                \
00037           etl_error_t *etl__err = (expression); \
00038           if (etl__err)                         \
00039             return etl__err;                    \
00040         } while (0)
00041 
00042 /** Successful return value for a function that returns @c etl_error_t. */
00043 #define ETL_SUCCESS NULL
00044 
00045 /** An exception object. */
00046 typedef struct {
00047   apr_status_t err;
00048   const char *msg;
00049 
00050   apr_uint32_t line;
00051   const char *file;
00052 
00053   apr_pool_t *pool;
00054 } etl_error_t;
00055 
00056 /**
00057  * Return a new @c etl_error_t with underlying @c apr_status_t @a err
00058  * and message @a msg.
00059  */
00060 #define etl_error_create(err, msg) etl_error_create_impl(err,      \
00061                                                          msg,      \
00062                                                          __LINE__, \
00063                                                          __FILE__)
00064 
00065 /**
00066  * The underlying function that implements @c etl_error_create.
00067  *
00068  * This is an implementation detail, and should not be directly called
00069  * by users.
00070  */
00071 etl_error_t *
00072 etl_error_create_impl(apr_status_t err,
00073                       const char *msg,
00074                       apr_uint32_t line,
00075                       const char *file);
00076 
00077 /**
00078  * Return a new @c etl_error_t with underlying @c apr_status_t @a err
00079  * and message created @c printf style with @a fmt and varargs.
00080  */
00081 #define etl_error_createf(err, fmt, ...) etl_error_createf_impl(err,         \
00082                                                                 __LINE__,    \
00083                                                                 __FILE__,    \
00084                                                                 fmt,         \
00085                                                                 __VA_ARGS__)
00086 
00087 /**
00088  * The underlying function that implements @c etl_error_createf.
00089  *
00090  * This is an implementation detail, and should not be directly called
00091  * by users.
00092  */
00093 etl_error_t *
00094 etl_error_createf_impl(apr_status_t err,
00095                        apr_uint32_t line,
00096                        const char *file,
00097                        const char *fmt,
00098                        ...);
00099 
00100 /** Destroy @a err. */
00101 void etl_error_clear(etl_error_t *err);
00102 
00103 #ifdef __cplusplus
00104 }
00105 #endif /* __cplusplus */
00106 
00107 #endif /* ETL_ERROR_H */

Generated on Sat Jun 3 10:17:28 2006 for ETL by  doxygen 1.4.4