/* Copyright 2006 Paul Querna * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @file pwt_error.h * @brief Error Objects for Proton. */ #ifndef PWT_ERROR_H #define PWT_ERROR_H #include #include #include /* Shamelessly copied from etl/include/etl_error.h */ #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /** * Check if the @c etl_error_t returned by @a expression is equal to * @c ETL_SUCCESS. If it is, do nothing, if not, then return it. */ #define PWT_ERR(expression) do { \ pwt_error_t *pwt__err = (expression); \ if (pwt__err) \ return pwt__err; \ } while (0) /** Successful return value for a function that returns @c etl_error_t. */ #define PWT_SUCCESS NULL /** An exception object. */ typedef struct { apr_status_t err; const char *msg; apr_uint32_t line; const char *file; apr_pool_t *pool; } pwt_error_t; /** * Return a new @c pwt_error_t with underlying @c apr_status_t @a err * and message @a msg. */ #define pwt_error_create(err, msg) pwt_error_create_impl(err, \ msg, \ __LINE__, \ __FILE__) /** * The underlying function that implements @c pwt_error_create. * * This is an implementation detail, and should not be directly called * by users. */ pwt_error_t * pwt_error_create_impl(apr_status_t err, const char *msg, apr_uint32_t line, const char *file); /** * Return a new @c pwt_error_t with underlying @c apr_status_t @a err * and message created @c printf style with @a fmt and varargs. */ #define pwt_error_createf(err, fmt, ...) pwt_error_createf_impl(err, \ __LINE__, \ __FILE__, \ fmt, \ __VA_ARGS__) /** * The underlying function that implements @c pwt_error_createf. * * This is an implementation detail, and should not be directly called * by users. */ pwt_error_t * pwt_error_createf_impl(apr_status_t err, apr_uint32_t line, const char *file, const char *fmt, ...); /** Destroy @a err. */ void pwt_error_destroy(pwt_error_t *err); #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* PWT_ERROR_H */