Skip to content

Commit 315a2d8

Browse files
committed
Add. URL errors
1 parent 44e86bb commit 315a2d8

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

src/lcerr_url.h

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#if LCURL_CURL_VER_GE(7,61,0)
2+
ERR_ENTRY ( BAD_HANDLE )
3+
ERR_ENTRY ( BAD_PARTPOINTER )
4+
ERR_ENTRY ( BAD_PORT_NUMBER )
5+
ERR_ENTRY ( MALFORMED_INPUT )
6+
ERR_ENTRY ( NO_FRAGMENT )
7+
ERR_ENTRY ( NO_HOST )
8+
ERR_ENTRY ( NO_OPTIONS )
9+
ERR_ENTRY ( NO_PASSWORD )
10+
ERR_ENTRY ( NO_PORT )
11+
ERR_ENTRY ( NO_QUERY )
12+
ERR_ENTRY ( NO_SCHEME )
13+
ERR_ENTRY ( NO_USER )
14+
ERR_ENTRY ( OK )
15+
ERR_ENTRY ( OUT_OF_MEMORY )
16+
ERR_ENTRY ( UNKNOWN_PART )
17+
ERR_ENTRY ( UNSUPPORTED_SCHEME)
18+
ERR_ENTRY ( URLDECODE )
19+
ERR_ENTRY ( USER_NOT_ALLOWED )
20+
#endif

src/lcerror.c

+26
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ static const char *LCURL_ERROR = LCURL_ERROR_NAME;
2020
#define LCURL_ERROR_MULTI_NAME "CURL-MULTI"
2121
#define LCURL_ERROR_SHARE_NAME "CURL-SHARE"
2222
#define LCURL_ERROR_FORM_NAME "CURL-FORM"
23+
#define LCURL_ERROR_URL_NAME "CURL-URL"
2324

2425
typedef struct lcurl_error_tag{
2526
int tp;
@@ -72,12 +73,24 @@ static const char* lcurl_err_form_mnemo(int err){
7273
#undef ERR_ENTRY
7374
}
7475

76+
static const char* lcurl_err_url_mnemo(int err){
77+
#define ERR_ENTRY(E) case CURLUE_##E: return #E;
78+
79+
switch (err){
80+
#include "lcerr_url.h"
81+
}
82+
return "UNKNOWN";
83+
84+
#undef ERR_ENTRY
85+
}
86+
7587
static const char* _lcurl_err_mnemo(int tp, int err){
7688
switch(tp){
7789
case LCURL_ERROR_EASY : return lcurl_err_easy_mnemo (err);
7890
case LCURL_ERROR_MULTI: return lcurl_err_multi_mnemo(err);
7991
case LCURL_ERROR_SHARE: return lcurl_err_share_mnemo(err);
8092
case LCURL_ERROR_FORM : return lcurl_err_form_mnemo (err);
93+
case LCURL_ERROR_URL : return lcurl_err_url_mnemo (err);
8194
}
8295
assert(0);
8396
return "<UNSUPPORTED ERROR TYPE>";
@@ -89,6 +102,7 @@ static const char* _lcurl_err_msg(int tp, int err){
89102
case LCURL_ERROR_MULTI: return curl_multi_strerror(err);
90103
case LCURL_ERROR_SHARE: return curl_share_strerror(err);
91104
case LCURL_ERROR_FORM : return lcurl_err_form_mnemo(err);
105+
case LCURL_ERROR_URL : return lcurl_err_url_mnemo(err);
92106
}
93107
assert(0);
94108
return "<UNSUPPORTED ERROR TYPE>";
@@ -100,6 +114,7 @@ static const char* _lcurl_err_category_name(int tp){
100114
(tp == LCURL_ERROR_MULTI) ||
101115
(tp == LCURL_ERROR_SHARE) ||
102116
(tp == LCURL_ERROR_FORM ) ||
117+
(tp == LCURL_ERROR_URL ) ||
103118
0
104119
);
105120

@@ -120,6 +135,10 @@ static const char* _lcurl_err_category_name(int tp){
120135
static const char *name = LCURL_ERROR_FORM_NAME;
121136
return name;
122137
}
138+
case LCURL_ERROR_URL: {
139+
static const char *name = LCURL_ERROR_URL_NAME;
140+
return name;
141+
}
123142
}
124143

125144
assert(0);
@@ -147,6 +166,7 @@ int lcurl_error_create(lua_State *L, int error_type, int no){
147166
(error_type == LCURL_ERROR_MULTI) ||
148167
(error_type == LCURL_ERROR_SHARE) ||
149168
(error_type == LCURL_ERROR_FORM ) ||
169+
(error_type == LCURL_ERROR_URL ) ||
150170
0
151171
);
152172

@@ -233,13 +253,15 @@ static const int ERROR_CATEGORIES[] = {
233253
LCURL_ERROR_MULTI,
234254
LCURL_ERROR_SHARE,
235255
LCURL_ERROR_FORM,
256+
LCURL_ERROR_URL,
236257
};
237258

238259
static const char* ERROR_CATEGORIES_NAME[] = {
239260
LCURL_ERROR_EASY_NAME,
240261
LCURL_ERROR_MULTI_NAME,
241262
LCURL_ERROR_SHARE_NAME,
242263
LCURL_ERROR_FORM_NAME,
264+
LCURL_ERROR_URL_NAME,
243265
NULL
244266
};
245267

@@ -297,6 +319,10 @@ static const lcurl_const_t lcurl_error_codes[] = {
297319

298320
#define ERR_ENTRY(N) { "E_FORM_"#N, CURL_FORMADD_##N },
299321
#include "lcerr_form.h"
322+
#undef ERR_ENTRY
323+
324+
#define ERR_ENTRY(N) { "E_URL_"#N, CURLUE_##N },
325+
#include "lcerr_url.h"
300326
#undef ERR_ENTRY
301327

302328
{NULL, 0}

src/lcerror.h

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#define LCURL_ERROR_MULTI 2
1919
#define LCURL_ERROR_SHARE 3
2020
#define LCURL_ERROR_FORM 4
21+
#define LCURL_ERROR_URL 5
2122

2223
#define LCURL_ERROR_RETURN 1
2324
#define LCURL_ERROR_RAISE 2

0 commit comments

Comments
 (0)