blob: 521876f74ed1fb400c86c1153985debb40638e95 [file] [log] [blame]
Willy Tarreaud740bab2007-10-28 11:14:07 +01001/*
Willy Tarreau8d366972020-05-27 16:10:29 +02002 * include/haproxy/errors.h
Willy Tarreauf25fbad2010-06-20 10:26:51 +02003 * Global error macros and constants
4 *
Willy Tarreau8d366972020-05-27 16:10:29 +02005 * Copyright (C) 2000-2020 Willy Tarreau - w@1wt.eu
Willy Tarreauf25fbad2010-06-20 10:26:51 +02006 *
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, version 2.1
10 * exclusively.
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 */
Willy Tarreaud740bab2007-10-28 11:14:07 +010021
Willy Tarreau8d366972020-05-27 16:10:29 +020022#ifndef _HAPROXY_ERRORS_H
23#define _HAPROXY_ERRORS_H
Willy Tarreaud740bab2007-10-28 11:14:07 +010024
Willy Tarreau36979d92020-06-05 17:27:29 +020025#include <stdio.h>
26
Willy Tarreaud740bab2007-10-28 11:14:07 +010027/* These flags may be used in various functions which are called from within
28 * loops (eg: to start all listeners from all proxies). They provide enough
29 * information to let the caller decide what to do. ERR_WARN and ERR_ALERT
30 * do not indicate any error, just that a message has been put in a shared
31 * buffer in order to be displayed by the caller.
32 */
33#define ERR_NONE 0x00 /* no error, no message returned */
34#define ERR_RETRYABLE 0x01 /* retryable error, may be cumulated */
35#define ERR_FATAL 0x02 /* fatal error, may be cumulated */
36#define ERR_ABORT 0x04 /* it's preferable to end any possible loop */
37#define ERR_WARN 0x08 /* a warning message has been returned */
38#define ERR_ALERT 0x10 /* an alert message has been returned */
39
Willy Tarreau6fb42e02007-10-28 17:02:33 +010040#define ERR_CODE (ERR_RETRYABLE|ERR_FATAL|ERR_ABORT) /* mask */
Willy Tarreaud740bab2007-10-28 11:14:07 +010041
Willy Tarreauf25fbad2010-06-20 10:26:51 +020042
43/* These codes may be used by config parsing functions which detect errors and
44 * which need to inform the upper layer about them. They are all prefixed with
45 * "PE_" for "Parse Error". These codes will probably be extended, and functions
46 * making use of them should be documented as such. Only code PE_NONE (zero) may
47 * indicate a valid condition, all other ones must be caught as errors, event if
48 * unknown by the caller. This must not be used to forward warnings.
49 */
50enum {
51 PE_NONE = 0, /* no error */
52 PE_ENUM_OOR, /* enum data out of allowed range */
53 PE_EXIST, /* trying to create something which already exists */
54 PE_ARG_MISSING, /* mandatory argument not provided */
55 PE_ARG_NOT_USED, /* argument provided cannot be used */
56 PE_ARG_INVC, /* invalid char in argument (pointer not provided) */
57 PE_ARG_INVC_PTR, /* invalid char in argument (pointer provided) */
58 PE_ARG_NOT_FOUND, /* argument references something not found */
59};
60
Willy Tarreau36979d92020-06-05 17:27:29 +020061
62/************ Error reporting functions from log.c ***********/
63
64/*
65 * Displays the message on stderr with the date and pid. Overrides the quiet
66 * mode during startup.
67 */
68void ha_alert(const char *fmt, ...)
69 __attribute__ ((format(printf, 1, 2)));
70
71/*
72 * Displays the message on stderr with the date and pid.
73 */
74void ha_warning(const char *fmt, ...)
75 __attribute__ ((format(printf, 1, 2)));
76
77/*
78 * Displays the message on stderr with the date and pid.
79 */
80void ha_notice(const char *fmt, ...)
81 __attribute__ ((format(printf, 1, 2)));
82
83/*
84 * Displays the message on <out> only if quiet mode is not set.
85 */
86void qfprintf(FILE *out, const char *fmt, ...)
87 __attribute__ ((format(printf, 2, 3)));
88
Willy Tarreau8d366972020-05-27 16:10:29 +020089#endif /* _HAPROXY_ERRORS_H */
Willy Tarreaud740bab2007-10-28 11:14:07 +010090
91/*
92 * Local variables:
93 * c-indent-level: 8
94 * c-basic-offset: 8
95 * End:
96 */