use existing result error in query_builder_exception constructor
This commit is contained in:
parent
72019bc1e7
commit
6629a71f6e
|
|
@ -198,10 +198,9 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj.is_transient()) {
|
if (obj.is_transient()) {
|
||||||
const auto result = processor.build(obj, true);
|
auto result = processor.build(obj, true);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
throw query_builder_exception(error_code::InvalidObject, "Invalid object");
|
throw query_builder_exception(result.release_error());
|
||||||
// return utils::failure(result.err());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -306,10 +305,9 @@ private:
|
||||||
|
|
||||||
insert_step_processor<PointerType> processor{ctx_};
|
insert_step_processor<PointerType> processor{ctx_};
|
||||||
|
|
||||||
const auto result = processor.build(obj);
|
auto result = processor.build(obj);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
throw query_builder_exception(error_code::InvalidObject, "Invalid object");
|
throw query_builder_exception(result.release_error());
|
||||||
// return utils::failure(result.err());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -330,16 +328,16 @@ private:
|
||||||
|
|
||||||
const auto it = ctx_.schema_.find(std::string{id});
|
const auto it = ctx_.schema_.find(std::string{id});
|
||||||
if (it == ctx_.schema_.end()) {
|
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()) {
|
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());
|
const auto cit = ctx_.contexts_by_type_.find(it->second.node().info().type_index());
|
||||||
if (cit == ctx_.contexts_by_type_.end()) {
|
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);
|
std::ignore = ctx_.processing_many_to_many_relations_.insert(key);
|
||||||
|
|
@ -351,11 +349,10 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj.is_transient()) {
|
if (obj.is_transient()) {
|
||||||
const auto result = processor.build(obj, true);
|
auto result = processor.build(obj, true);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
throw query_builder_exception(error_code::InvalidObject, "Invalid object");
|
throw query_builder_exception(result.release_error());
|
||||||
// return utils::failure(result.err());
|
};
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto rel = make_relation(obj);
|
auto rel = make_relation(obj);
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,8 @@ namespace matador::query {
|
||||||
|
|
||||||
class query_builder_exception final : public std::exception {
|
class query_builder_exception final : public std::exception {
|
||||||
public:
|
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;
|
[[nodiscard]] const utils::error &error() const;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
#include "matador/query/query_builder_exception.hpp"
|
#include "matador/query/query_builder_exception.hpp"
|
||||||
|
|
||||||
namespace matador::query {
|
namespace matador::query {
|
||||||
|
query_builder_exception::query_builder_exception(utils::error &&err)
|
||||||
|
: error_(std::move(err)) {}
|
||||||
|
|
||||||
query_builder_exception::query_builder_exception(const error_code error, std::string&& msg)
|
query_builder_exception::query_builder_exception(const error_code error, std::string&& msg)
|
||||||
: error_(error, msg)
|
: error_(error, msg)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue