[PATCH 2/2] quest: Output errors and meta informations to stderr
Jerabek Vladimir
vladimir.jerabek at fio.cz
Thu Nov 14 16:20:08 GMT 2019
---
xapian-core/examples/quest.cc | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/xapian-core/examples/quest.cc b/xapian-core/examples/quest.cc
index 9953861d8ce9..831d4a87c5cb 100644
--- a/xapian-core/examples/quest.cc
+++ b/xapian-core/examples/quest.cc
@@ -398,14 +398,14 @@ try {
Xapian::Query query = parser.parse_query(argv[optind], flags);
const string & correction = parser.get_corrected_query_string();
if (!correction.empty())
- cout << "Did you mean: " << correction << "\n\n";
+ cerr << "Did you mean: " << correction << "\n\n";
if (!quiet) {
- cout << "Parsed Query: " << query.get_description() << endl;
+ cerr << "Parsed Query: " << query.get_description() << endl;
}
if (!have_database) {
- cout << "No database specified so not running the query." << endl;
+ cerr << "No database specified so not running the query." << endl;
exit(0);
}
@@ -468,15 +468,17 @@ try {
if (!quiet) {
if (lower_bound == upper_bound) {
- cout << "Exactly " << estimate << " matches" << endl;
+ cerr << "Exactly " << estimate << " matches" << endl;
} else {
- cout << "Between " << lower_bound << " and " << upper_bound
+ cerr << "Between " << lower_bound << " and " << upper_bound
<< " matches, best estimate is " << estimate << endl;
}
- cout << "MSet:" << endl;
+ cerr << "MSet:" << endl;
}
+ cerr << flush;
+
for (Xapian::MSetIterator i = mset.begin(); i != mset.end(); ++i) {
Xapian::Document doc = i.get_document();
string data = doc.get_data();
@@ -489,9 +491,9 @@ try {
}
cout << flush;
} catch (const Xapian::QueryParserError & e) {
- cout << "Couldn't parse query: " << e.get_msg() << endl;
+ cerr << "Couldn't parse query: " << e.get_msg() << endl;
exit(1);
} catch (const Xapian::Error & err) {
- cout << err.get_description() << endl;
+ cerr << err.get_description() << endl;
exit(1);
}
--
2.20.1
More information about the Xapian-devel
mailing list