torque  6.0.1
 All Data Structures Files Functions Variables Modules
error.h
Go to the documentation of this file.
1 /* $Id: error.h,v 1.4 2006/09/08 18:18:08 ciesnik Exp $ */
2 /*
3  * DRMAA library for Torque/PBS
4  * Copyright (C) 2006 Poznan Supercomputing and Networking Center
5  * DSP team <dsp-devel@hedera.man.poznan.pl>
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
27 #ifndef __DRMAA__ERROR_H
28 #define __DRMAA__ERROR_H
29 
30 #ifdef HAVE_CONFIG_H
31 # include <pbs_config.h>
32 #endif
33 
34 #include <stddef.h>
35 
36 
37 int drmaa_get_errno_error(char *error_diagnosis, size_t error_diag_len);
38 int drmaa_get_drmaa_error(char *error_diagnosis, size_t error_diag_len,
39  int error_code);
40 int drmaa_get_pbs_error(char *error_diagnosis, size_t error_diag_len);
41 
42 int drmaa_map_pbs_error(int pbs_errcode);
43 
44 void drmaa_log(const char *fmt, ...)
45 __attribute__((format(printf, 1, 2)));
46 
47 
48 #if DRMAA_DEBUG
49 # define DEBUG( args ) do{ drmaa_log args ; }while(0)
50 #else
51 # define DEBUG( args ) /* nothing */
52 #endif
53 
54 #define STORE_ERRNO_MSG() \
55  do{ drmaa_get_errno_error( errmsg, errlen ); }while(0)
56 
57 #define RAISE_ERRNO( retcode ) do { \
58  STORE_ERRNO_MSG(); \
59  return retcode; \
60  } while(0)
61 
62 #define SET_DRMAA_ERROR( retcode ) \
63  do{ drmaa_get_drmaa_error( errmsg, errlen, (retcode) ); } while(0)
64 
65 #define RAISE_DRMAA( retcode ) do { \
66  SET_DRMAA_ERROR( retcode ); \
67  return retcode; \
68  } while(0)
69 
70 #define RAISE_NO_MEMORY() \
71  RAISE_DRMAA( DRMAA_ERRNO_NO_MEMORY )
72 
73 #define RAISE_PBS() \
74  do{ return drmaa_get_pbs_error( errmsg, errlen ); } while(0)
75 
76 #define SET_PBS_ERROR( rc_var ) \
77  do{ (rc_var) = drmaa_get_pbs_error( errmsg, errlen ); } while(0)
78 
79 
80 #endif /* __DRMAA__ERROR_H */
81 
int drmaa_get_errno_error(char *error_diagnosis, size_t error_diag_len)
Gets last system error message and returns its code.
Definition: error.c:54
int drmaa_get_pbs_error(char *error_diagnosis, size_t error_diag_len)
Retrieves last PBS error message.
Definition: error.c:74
int drmaa_map_pbs_error(int pbs_errcode)
Maps PBS error code into DMRAA code.
Definition: error.c:218