projects
/
pazpar2-moved-to-github.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
5b752bf
)
Better error message for CCL parse errors PAZ-887
author
Adam Dickmeiss
<adam@indexdata.dk>
Mon, 11 Nov 2013 12:55:37 +0000
(13:55 +0100)
committer
Adam Dickmeiss
<adam@indexdata.dk>
Mon, 11 Nov 2013 12:55:37 +0000
(13:55 +0100)
src/client.c
patch
|
blob
|
history
src/client.h
patch
|
blob
|
history
src/http_command.c
patch
|
blob
|
history
src/session.c
patch
|
blob
|
history
src/session.h
patch
|
blob
|
history
test/test_http_56.res
patch
|
blob
|
history
test/test_url_14.res
patch
|
blob
|
history
diff --git
a/src/client.c
b/src/client.c
index
a8dde60
..
634243c
100644
(file)
--- a/
src/client.c
+++ b/
src/client.c
@@
-1342,7
+1342,7
@@
static int apply_limit(struct session_database *sdb,
// return -1 on query error
// return -2 on limit error
int client_parse_query(struct client *cl, const char *query,
// return -1 on query error
// return -2 on limit error
int client_parse_query(struct client *cl, const char *query,
- facet_limits_t facet_limits)
+ facet_limits_t facet_limits, const char **error_msg)
{
struct session *se = client_get_session(cl);
struct conf_service *service = se->service;
{
struct session *se = client_get_session(cl);
struct conf_service *service = se->service;
@@
-1387,6
+1387,8
@@
int client_parse_query(struct client *cl, const char *query,
ccl_qual_rm(&ccl_map);
if (!cn)
{
ccl_qual_rm(&ccl_map);
if (!cn)
{
+ if (error_msg)
+ *error_msg = ccl_err_msg(cerror);
client_set_state(cl, Client_Error);
session_log(se, YLOG_WARN, "Client %s: Failed to parse CCL query '%s'",
client_get_id(cl),
client_set_state(cl, Client_Error);
session_log(se, YLOG_WARN, "Client %s: Failed to parse CCL query '%s'",
client_get_id(cl),
@@
-1445,6
+1447,7
@@
int client_parse_query(struct client *cl, const char *query,
session_log(se, YLOG_WARN, "Invalid PQF query for Client %s: %s",
client_get_id(cl), cl->pquery);
ret_value = -1;
session_log(se, YLOG_WARN, "Invalid PQF query for Client %s: %s",
client_get_id(cl), cl->pquery);
ret_value = -1;
+ *error_msg = "Invalid PQF after CCL to PQF conversion";
}
else
{
}
else
{
@@
-1459,7
+1462,10
@@
int client_parse_query(struct client *cl, const char *query,
else
cl->cqlquery = make_cqlquery(cl, zquery);
if (!cl->cqlquery)
else
cl->cqlquery = make_cqlquery(cl, zquery);
if (!cl->cqlquery)
+ {
+ *error_msg = "Cannot convert PQF to Solr/CQL";
ret_value = -1;
ret_value = -1;
+ }
else
session_log(se, YLOG_LOG, "Client %s native query: %s (%s)",
client_get_id(cl), cl->cqlquery, sru);
else
session_log(se, YLOG_LOG, "Client %s native query: %s (%s)",
client_get_id(cl), cl->cqlquery, sru);
diff --git
a/src/client.h
b/src/client.h
index
550eabe
..
b78317a
100644
(file)
--- a/
src/client.h
+++ b/
src/client.h
@@
-84,7
+84,7
@@
int client_is_active_preferred(struct client *cl);
struct client *client_next_in_session(struct client *cl);
int client_parse_query(struct client *cl, const char *query,
struct client *client_next_in_session(struct client *cl);
int client_parse_query(struct client *cl, const char *query,
- facet_limits_t facet_limits);
+ facet_limits_t facet_limits, const char **error_msg);
Odr_int client_get_hits(struct client *cl);
Odr_int client_get_approximation(struct client *cl);
int client_get_num_records(struct client *cl);
Odr_int client_get_hits(struct client *cl);
Odr_int client_get_approximation(struct client *cl);
int client_get_num_records(struct client *cl);
diff --git
a/src/http_command.c
b/src/http_command.c
index
30de3d8
..
f11ae21
100644
(file)
--- a/
src/http_command.c
+++ b/
src/http_command.c
@@
-263,9
+263,9
@@
static const char *get_msg(enum pazpar2_error_code code)
return "No error";
}
return "No error";
}
-static void error(struct http_response *rs,
- enum pazpar2_error_code code,
- const char *addinfo)
+static void error2(struct http_response *rs,
+ enum pazpar2_error_code code,
+ const char *addinfo, const char *addinfo2)
{
struct http_channel *c = rs->channel;
WRBUF text = wrbuf_alloc();
{
struct http_channel *c = rs->channel;
WRBUF text = wrbuf_alloc();
@@
-278,7
+278,14
@@
static void error(struct http_response *rs,
wrbuf_printf(text, HTTP_COMMAND_RESPONSE_PREFIX
"<error code=\"%d\" msg=\"%s\">", (int) code, msg);
if (addinfo)
wrbuf_printf(text, HTTP_COMMAND_RESPONSE_PREFIX
"<error code=\"%d\" msg=\"%s\">", (int) code, msg);
if (addinfo)
+ {
wrbuf_xmlputs(text, addinfo);
wrbuf_xmlputs(text, addinfo);
+ if (addinfo2)
+ {
+ wrbuf_xmlputs(text, ": ");
+ wrbuf_xmlputs(text, addinfo2);
+ }
+ }
wrbuf_puts(text, "</error>");
yaz_log(YLOG_WARN, "HTTP %s %s%s%s", http_status,
wrbuf_puts(text, "</error>");
yaz_log(YLOG_WARN, "HTTP %s %s%s%s", http_status,
@@
-288,6
+295,13
@@
static void error(struct http_response *rs,
http_send_response(c);
}
http_send_response(c);
}
+static void error(struct http_response *rs,
+ enum pazpar2_error_code code,
+ const char *addinfo)
+{
+ return error2(rs, code, addinfo, 0);
+}
+
static void response_open_command(struct http_channel *c, const char *command)
{
wrbuf_rewind(c->wrbuf);
static void response_open_command(struct http_channel *c, const char *command)
{
wrbuf_rewind(c->wrbuf);
@@
-1361,6
+1375,7
@@
static void cmd_search(struct http_channel *c)
const char *rank = http_argbyname(rq, "rank");
enum pazpar2_error_code code;
const char *addinfo = 0;
const char *rank = http_argbyname(rq, "rank");
enum pazpar2_error_code code;
const char *addinfo = 0;
+ const char *addinfo2 = 0;
struct reclist_sortparms *sp;
struct conf_service *service = 0;
struct reclist_sortparms *sp;
struct conf_service *service = 0;
@@
-1391,10
+1406,10
@@
static void cmd_search(struct http_channel *c)
}
code = session_search(s->psession, query, startrecs, maxrecs, filter, limit,
}
code = session_search(s->psession, query, startrecs, maxrecs, filter, limit,
- &addinfo, sp, mergekey, rank);
+ &addinfo, &addinfo2, sp, mergekey, rank);
if (code)
{
if (code)
{
- error(rs, code, addinfo);
+ error2(rs, code, addinfo, addinfo2);
release_session(c, s);
return;
}
release_session(c, s);
return;
}
diff --git
a/src/session.c
b/src/session.c
index
489d7ea
..
95d83ca
100644
(file)
--- a/
src/session.c
+++ b/
src/session.c
@@
-748,6
+748,7
@@
enum pazpar2_error_code session_search(struct session *se,
const char *filter,
const char *limit,
const char **addinfo,
const char *filter,
const char *limit,
const char **addinfo,
+ const char **addinfo2,
struct reclist_sortparms *sp,
const char *mergekey,
const char *rank)
struct reclist_sortparms *sp,
const char *mergekey,
const char *rank)
@@
-818,7
+819,7
@@
enum pazpar2_error_code session_search(struct session *se,
if (prepare_map(se, client_get_database(cl)) < 0)
continue;
if (prepare_map(se, client_get_database(cl)) < 0)
continue;
- parse_ret = client_parse_query(cl, query, se->facet_limits);
+ parse_ret = client_parse_query(cl, query, se->facet_limits, addinfo2);
if (parse_ret == -1)
no_failed_query++;
else if (parse_ret == -2)
if (parse_ret == -1)
no_failed_query++;
else if (parse_ret == -2)
diff --git
a/src/session.h
b/src/session.h
index
de5427f
..
85f1b8f
100644
(file)
--- a/
src/session.h
+++ b/
src/session.h
@@
-159,6
+159,7
@@
enum pazpar2_error_code session_search(struct session *s, const char *query,
const char *maxrecs,
const char *filter, const char *limit,
const char **addinfo,
const char *maxrecs,
const char *filter, const char *limit,
const char **addinfo,
+ const char **addinfo2,
struct reclist_sortparms *sort_parm,
const char *mergekey,
const char *rank);
struct reclist_sortparms *sort_parm,
const char *mergekey,
const char *rank);
diff --git
a/test/test_http_56.res
b/test/test_http_56.res
index
e2db1ca
..
f97f596
100644
(file)
--- a/
test/test_http_56.res
+++ b/
test/test_http_56.res
@@
-1,2
+1,2
@@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
-<error code="3" msg="Malformed parameter value">query</error>
\ No newline at end of file
+<error code="3" msg="Malformed parameter value">query: Search word expected</error>
\ No newline at end of file
diff --git
a/test/test_url_14.res
b/test/test_url_14.res
index
e2db1ca
..
f74b589
100644
(file)
--- a/
test/test_url_14.res
+++ b/
test/test_url_14.res
@@
-1,2
+1,2
@@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
-<error code="3" msg="Malformed parameter value">query</error>
\ No newline at end of file
+<error code="3" msg="Malformed parameter value">query: Invalid PQF after CCL to PQF conversion</error>
\ No newline at end of file