lib: Use Mu:Error exception

Where applicable.
This commit is contained in:
Dirk-Jan C. Binnema
2019-12-30 22:28:53 +02:00
parent dfafecaf0c
commit 97afdd9e3c
7 changed files with 37 additions and 24 deletions

View File

@ -19,6 +19,7 @@
#include "parser.hh"
#include "tokenizer.hh"
#include "utils/mu-utils.hh"
#include "utils/mu-error.hh"
using namespace Mu;
@ -36,7 +37,7 @@ using namespace Mu;
// <regex> -> [field:]/regex/
#define BUG(...) std::runtime_error (format("%u: BUG: ",__LINE__) \
#define BUG(...) Mu::Error (Error::Code::Internal, format("%u: BUG: ",__LINE__) \
+ format(__VA_ARGS__))
static Token

View File

@ -25,6 +25,7 @@
#include <iostream>
#include <parser/data.hh>
#include <utils/mu-error.hh>
namespace Mu {
@ -62,7 +63,7 @@ struct Node {
case Type::Range: return "range"; break;
case Type::Invalid: return "<invalid>"; break;
default:
throw std::runtime_error ("bug");
throw Mu::Error(Error::Code::Internal, "unexpected type");
}
}

View File

@ -23,6 +23,7 @@
#include <xapian.h>
#include "parser/xapian.hh"
#include <utils/mu-error.hh>
using namespace Mu;
@ -42,7 +43,7 @@ xapian_query_op (const Mu::Tree& tree)
case Node::Type::OpOr: op = Xapian::Query::OP_OR; break;
case Node::Type::OpXor: op = Xapian::Query::OP_XOR; break;
case Node::Type::OpAndNot: op = Xapian::Query::OP_AND_NOT; break;
default: throw std::runtime_error ("invalid op"); // bug
default: throw Mu::Error (Error::Code::Internal, "invalid op"); // bug
}
std::vector<Xapian::Query> childvec;
@ -114,6 +115,6 @@ Mu::xapian_query (const Mu::Tree& tree)
case Node::Type::Range:
return xapian_query_range (tree);
default:
throw std::runtime_error ("invalid query"); // bug
throw Mu::Error (Error::Code::Internal, "invalid query"); // bug
}
}