]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[MINOR] errors: provide new status codes for config parsing functions
authorWilly Tarreau <w@1wt.eu>
Sun, 20 Jun 2010 08:26:51 +0000 (10:26 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 10 Aug 2010 12:01:15 +0000 (14:01 +0200)
Some config parsing functions need to return composite status codes
when they rely on other functions. Let's provide a few such codes
for general use and extend them later.

include/common/errors.h

index 449f2a873c6794817bebbdf7d8e24b4c9df93df7..e6b658b1f627f99c5af03f0b37c6c355cdc97628 100644 (file)
@@ -1,23 +1,23 @@
 /*
-  include/common/errors.h
-  Global error macros and constants
-
 Copyright (C) 2000-2007 Willy Tarreau - w@1wt.eu
-  
-  This library is free software; you can redistribute it and/or
-  modify it under the terms of the GNU Lesser General Public
-  License as published by the Free Software Foundation, version 2.1
-  exclusively.
-
-  This library 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
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public
-  License along with this library; if not, write to the Free Software
-  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
-*/
* include/common/errors.h
* Global error macros and constants
+ *
* Copyright (C) 2000-2010 Willy Tarreau - w@1wt.eu
+ *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation, version 2.1
* exclusively.
+ *
* This library 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
* Lesser General Public License for more details.
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
 
 #ifndef _COMMON_ERRORS_H
 #define _COMMON_ERRORS_H
 
 #define ERR_CODE       (ERR_RETRYABLE|ERR_FATAL|ERR_ABORT)     /* mask */
 
+
+/* These codes may be used by config parsing functions which detect errors and
+ * which need to inform the upper layer about them. They are all prefixed with
+ * "PE_" for "Parse Error". These codes will probably be extended, and functions
+ * making use of them should be documented as such. Only code PE_NONE (zero) may
+ * indicate a valid condition, all other ones must be caught as errors, event if
+ * unknown by the caller. This must not be used to forward warnings.
+ */
+enum {
+       PE_NONE = 0,      /* no error */
+       PE_ENUM_OOR,      /* enum data out of allowed range */
+       PE_EXIST,         /* trying to create something which already exists */
+       PE_ARG_MISSING,   /* mandatory argument not provided */
+       PE_ARG_NOT_USED,  /* argument provided cannot be used */
+       PE_ARG_INVC,      /* invalid char in argument (pointer not provided) */
+       PE_ARG_INVC_PTR,  /* invalid char in argument (pointer provided) */
+       PE_ARG_NOT_FOUND, /* argument references something not found */
+};
+
 #endif /* _COMMON_ERRORS_H */
 
 /*