File: error.c

package info (click to toggle)
wget2 2.2.0%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 22,468 kB
  • sloc: ansic: 121,166; sh: 11,559; makefile: 878; xml: 182; sed: 16
file content (61 lines) | stat: -rw-r--r-- 2,027 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
 * Copyright (c) 2018-2024 Free Software Foundation, Inc.
 *
 * This file is part of libwget.
 *
 * Libwget 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, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Libwget 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 libwget.  If not, see <https://www.gnu.org/licenses/>.
 */

#include <config.h>

#include <wget.h>
#include "private.h"

/**
 * \file
 * \brief Error functions
 * \defgroup libwget-error Error functions
 * @{
 *
 * Here are th implementations of libwget error functions.
 */

/**
 * \param[in] rc Error code from another libwget function
 * \return A humanly readable string describing error
 *
 * Convert an internal libwget error code to a humanly readable string.
 * The returned pointer must not be de-allocated by the caller.
 */
const char *wget_strerror(wget_error err)
{
	switch (err) {
	case WGET_E_SUCCESS: return _("Success");
	case WGET_E_UNKNOWN: return _("General error");
	case WGET_E_MEMORY: return _("No memory");
	case WGET_E_INVALID: return _("Invalid value");
	case WGET_E_TIMEOUT: return _("Timeout");
	case WGET_E_CONNECT: return _("Connect error");
	case WGET_E_HANDSHAKE: return _("Handshake error");
	case WGET_E_CERTIFICATE: return _("Certificate error");
	case WGET_E_TLS_DISABLED: return _("libwget has been built without TLS support");
	case WGET_E_XML_PARSE_ERR: return _("Failed to parse XML");
	case WGET_E_OPEN: return _("Failed to open file");
	case WGET_E_IO: return _("I/O error");
	case WGET_E_UNSUPPORTED: return _("Unsupported function");
	default: return _("Unknown error");
	}
}

/**@}*/