Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-22 10:38:43

0001 /*
0002  * Copyright (c) CERN 2013-2017
0003  *
0004  * Copyright (c) Members of the EMI Collaboration. 2010-2013
0005  *  See  http://www.eu-emi.eu/partners for details on the copyright
0006  *  holders.
0007  *
0008  * Licensed under the Apache License, Version 2.0 (the "License");
0009  * you may not use this file except in compliance with the License.
0010  * You may obtain a copy of the License at
0011  *
0012  *    http://www.apache.org/licenses/LICENSE-2.0
0013  *
0014  * Unless required by applicable law or agreed to in writing, software
0015  * distributed under the License is distributed on an "AS IS" BASIS,
0016  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0017  * See the License for the specific language governing permissions and
0018  * limitations under the License.
0019  */
0020 
0021 #pragma once
0022 #ifndef GFAL_COMMON_ERR_HELPERS_H_
0023 #define GFAL_COMMON_ERR_HELPERS_H_
0024 
0025 #include "gfal_common.h"
0026 #include <errno.h>
0027 
0028 #if !defined(__GFAL2_H_INSIDE__) && !defined(__GFAL2_BUILD__)
0029 #   warning "Direct inclusion of gfal2 headers is deprecated. Please, include only gfal_api.h or gfal_plugins_api.h"
0030 #endif
0031 
0032 #ifdef __cplusplus
0033 extern "C" {
0034 #endif
0035 
0036 
0037 /** @def Wraps g_set_error and appends the function name
0038  *       only if DEBUG is enabled
0039  */
0040 void gfal2_set_error(GError       **err,
0041                      GQuark         domain,
0042                      gint           code,
0043                      const gchar   *function,
0044                      const gchar   *format,
0045                      ...) G_GNUC_PRINTF (5, 6);
0046 
0047 /** @def Wraps g_propagate_prefixed_error, and appends
0048  *       the function name only if DEBUG is enabled
0049  *       fmt is always appended
0050  */
0051 void gfal2_propagate_prefixed_error_extended(GError       **dest,
0052                                     GError        *src,
0053                                     const gchar   *function,
0054                                     const gchar   *format,
0055                                     ...) G_GNUC_PRINTF (4, 5);
0056 
0057 /** @def Wraps g_propagate_prefixed_error, and appends
0058  *       the function name only if DEBUG is enabled
0059  */
0060 void gfal2_propagate_prefixed_error(GError       **dest,
0061                                     GError        *src,
0062                                     const gchar   *function);
0063 
0064 
0065 #ifdef __cplusplus
0066 }
0067 #endif
0068 
0069 /** @def macro for error error report on args
0070  *
0071  */
0072 #define g_return_val_err_if_fail(exp, val, err, msg) if(!(exp)){ g_set_error(err, gfal2_get_core_quark(), EINVAL, msg); return val; }
0073 
0074 /** @def macro for one-line return with error management exception-like
0075  */
0076 #define G_RETURN_ERR(ret, tmp_err, err) \
0077 if(tmp_err)\
0078     gfal2_propagate_prefixed_error(err, tmp_err, __func__);\
0079 return ret
0080 
0081 #endif /* GFAL_COMMON_ERR_HELPERS_H_ */