use existing result error in query_builder_exception constructor
This commit is contained in:
@@ -198,10 +198,9 @@ public:
|
||||
}
|
||||
|
||||
if (obj.is_transient()) {
|
||||
const auto result = processor.build(obj, true);
|
||||
auto result = processor.build(obj, true);
|
||||
if (!result) {
|
||||
throw query_builder_exception(error_code::InvalidObject, "Invalid object");
|
||||
// return utils::failure(result.err());
|
||||
throw query_builder_exception(result.release_error());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -306,10 +305,9 @@ private:
|
||||
|
||||
insert_step_processor<PointerType> processor{ctx_};
|
||||
|
||||
const auto result = processor.build(obj);
|
||||
auto result = processor.build(obj);
|
||||
if (!result) {
|
||||
throw query_builder_exception(error_code::InvalidObject, "Invalid object");
|
||||
// return utils::failure(result.err());
|
||||
throw query_builder_exception(result.release_error());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -330,16 +328,16 @@ private:
|
||||
|
||||
const auto it = ctx_.schema_.find(std::string{id});
|
||||
if (it == ctx_.schema_.end()) {
|
||||
throw query_builder_exception(error_code::UnknownType, "Unknown type");
|
||||
throw query_builder_exception(error_code::UnknownType, "Unknown type for relation " + std::string{id});
|
||||
}
|
||||
|
||||
if (std::type_index(typeid(LocalType)) != it->second.node().info().type_index()) {
|
||||
throw query_builder_exception(error_code::InvalidRelationType, "Invalid relation type");
|
||||
throw query_builder_exception(error_code::InvalidRelationType, "Invalid relation type for " + std::string{id});
|
||||
}
|
||||
|
||||
const auto cit = ctx_.contexts_by_type_.find(it->second.node().info().type_index());
|
||||
if (cit == ctx_.contexts_by_type_.end()) {
|
||||
throw query_builder_exception(error_code::UnknownType, "Unknown type");
|
||||
throw query_builder_exception(error_code::UnknownType, "No query contexts for type " + it->second.node().name());
|
||||
}
|
||||
|
||||
std::ignore = ctx_.processing_many_to_many_relations_.insert(key);
|
||||
@@ -351,11 +349,10 @@ private:
|
||||
}
|
||||
|
||||
if (obj.is_transient()) {
|
||||
const auto result = processor.build(obj, true);
|
||||
auto result = processor.build(obj, true);
|
||||
if (!result) {
|
||||
throw query_builder_exception(error_code::InvalidObject, "Invalid object");
|
||||
// return utils::failure(result.err());
|
||||
}
|
||||
throw query_builder_exception(result.release_error());
|
||||
};
|
||||
}
|
||||
|
||||
auto rel = make_relation(obj);
|
||||
|
||||
@@ -11,7 +11,8 @@ namespace matador::query {
|
||||
|
||||
class query_builder_exception final : public std::exception {
|
||||
public:
|
||||
explicit query_builder_exception(error_code error, std::string &&msg);
|
||||
explicit query_builder_exception(utils::error &&err);
|
||||
query_builder_exception(error_code error, std::string &&msg);
|
||||
|
||||
[[nodiscard]] const utils::error &error() const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user