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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* soup-error.c: Errorcode description and class lookup
*
* Authors:
* Alex Graveley (alex@ximian.com)
*
* Copyright (C) 2001-2002, Ximian, Inc.
*/
#include <glib.h>
#include "soup-error.h"
struct {
guint sc;
const gchar *phrase;
} error_code_phrases [] = {
/*
* SOUP_ERROR_CLASS_TRANSPORT
*/
{ SOUP_ERROR_CANCELLED, "Cancelled" },
{ SOUP_ERROR_CANT_CONNECT, "Cannot connect to destination" },
{ SOUP_ERROR_CANT_CONNECT_PROXY, "Cannot connect to proxy" },
{ SOUP_ERROR_IO, "Connection terminated "
"unexpectedly" },
{ SOUP_ERROR_MALFORMED, "Message corrupt" },
{ SOUP_ERROR_CANT_RESOLVE, "Host name lookup failed" },
{ SOUP_ERROR_CANT_RESOLVE_PROXY, "Proxy host name lookup failed" },
/*
* SOUP_ERROR_CLASS_INFORMATIONAL
*/
{ SOUP_ERROR_CONTINUE, "Continue" },
{ SOUP_ERROR_PROTOCOL_SWITCH, "Protocol Switch" },
{ SOUP_ERROR_DAV_PROCESSING, "Processing" },
/*
* SOUP_ERROR_CLASS_SUCCESS
*/
{ SOUP_ERROR_OK, "OK" },
{ SOUP_ERROR_CREATED, "Created" },
{ SOUP_ERROR_ACCEPTED, "Accepted" },
{ SOUP_ERROR_NON_AUTHORITATIVE, "Non-Authoritative" },
{ SOUP_ERROR_NO_CONTENT, "No Content" },
{ SOUP_ERROR_RESET_CONTENT, "Reset Content" },
{ SOUP_ERROR_PARTIAL_CONTENT, "Partial Content" },
{ SOUP_ERROR_DAV_MULTISTATUS, "Multi-Status" },
/*
* SOUP_ERROR_CLASS_REDIRECT
*/
{ SOUP_ERROR_MULTIPLE_CHOICES, "Multiple Choices" },
{ SOUP_ERROR_MOVED_PERMANENTLY, "Moved Permanently" },
{ SOUP_ERROR_FOUND, "Found" },
{ SOUP_ERROR_SEE_OTHER, "See Other" },
{ SOUP_ERROR_NOT_MODIFIED, "Not Modified" },
{ SOUP_ERROR_USE_PROXY, "Use Proxy" },
{ SOUP_ERROR_TEMPORARY_REDIRECT, "Temporary Redirect" },
/*
* SOUP_ERROR_CLASS_CLIENT_ERROR
*/
{ SOUP_ERROR_BAD_REQUEST, "Bad Request" },
{ SOUP_ERROR_UNAUTHORIZED, "Unauthorized" },
{ SOUP_ERROR_PAYMENT_REQUIRED, "Payment Required" },
{ SOUP_ERROR_FORBIDDEN, "Forbidden" },
{ SOUP_ERROR_NOT_FOUND, "Not Found" },
{ SOUP_ERROR_METHOD_NOT_ALLOWED, "Method Not Allowed" },
{ SOUP_ERROR_NOT_ACCEPTABLE, "Not Acceptable" },
{ SOUP_ERROR_PROXY_UNAUTHORIZED, "Proxy Unauthorized" },
{ SOUP_ERROR_TIMED_OUT, "Timed Out" },
{ SOUP_ERROR_CONFLICT, "Conflict" },
{ SOUP_ERROR_GONE, "Gone" },
{ SOUP_ERROR_LENGTH_REQUIRED, "Length Required" },
{ SOUP_ERROR_PRECONDITION_FAILED, "Precondition Failed" },
{ SOUP_ERROR_BODY_TOO_LARGE, "Entity Body Too Large" },
{ SOUP_ERROR_URI_TOO_LARGE, "Request-URI Too Large" },
{ SOUP_ERROR_UNKNOWN_MEDIA_TYPE, "Unknown Media Type" },
{ SOUP_ERROR_INVALID_RANGE, "Invalid Range" },
{ SOUP_ERROR_EXPECTATION_FAILED, "Expectation Failed" },
{ SOUP_ERROR_DAV_UNPROCESSABLE, "Unprocessable Entity" },
{ SOUP_ERROR_DAV_LOCKED, "Locked" },
{ SOUP_ERROR_DAV_DEPENDENCY_FAILED, "Dependency Failed" },
/*
* SOUP_ERROR_CLASS_SERVER_ERROR
*/
{ SOUP_ERROR_INTERNAL, "Internal Server Error" },
{ SOUP_ERROR_NOT_IMPLEMENTED, "Not Implemented" },
{ SOUP_ERROR_BAD_GATEWAY, "Bad Gateway" },
{ SOUP_ERROR_SERVICE_UNAVAILABLE, "Service Unavailable" },
{ SOUP_ERROR_GATEWAY_TIMEOUT, "Gateway Timeout" },
{ SOUP_ERROR_VERSION_UNSUPPORTED, "Version Unsupported" },
{ SOUP_ERROR_DAV_OUT_OF_SPACE, "Out Of Space" },
{ 0 }
};
const gchar *
soup_error_get_phrase (SoupKnownErrorCode errcode)
{
gint i;
for (i = 0; error_code_phrases [i].sc; i++) {
if (error_code_phrases [i].sc == (guint) errcode)
return error_code_phrases [i].phrase;
}
return "Unknown Error";
}
SoupErrorClass
soup_error_get_class (SoupKnownErrorCode errcode)
{
if (errcode < 100) return SOUP_ERROR_CLASS_TRANSPORT;
if (errcode < 200) return SOUP_ERROR_CLASS_INFORMATIONAL;
if (errcode < 300) return SOUP_ERROR_CLASS_SUCCESS;
if (errcode < 400) return SOUP_ERROR_CLASS_REDIRECT;
if (errcode < 500) return SOUP_ERROR_CLASS_CLIENT_ERROR;
if (errcode < 600) return SOUP_ERROR_CLASS_SERVER_ERROR;
return SOUP_ERROR_CLASS_UNKNOWN;
}
|