change error system & function signatures

Signed-off-by: Folling <mail@folling.io>
This commit is contained in:
Folling 2024-01-02 15:14:39 +01:00 committed by Folling
parent 1367373819
commit e1bf97704a
No known key found for this signature in database
28 changed files with 633 additions and 651 deletions

View file

@ -5,7 +5,6 @@
#include <ikarus/objects/properties/property_type.h>
#include <objects/properties/property_source.hpp>
#include <persistence/function_context.hpp>
#include <persistence/project.hpp>
#include <sys/stat.h>
#include <values/value.hpp>
@ -23,12 +22,10 @@ IkarusProperty::Data const & IkarusProperty::get_data() const {
}
cppbase::Result<IkarusPropertyType, sqlitecpp::SingleQueryError> IkarusProperty::get_property_type(IkarusProject * project, IkarusId id) {
auto * ctx = project->get_function_context();
VTRY(
auto const type,
project->get_db()->query_one<int>("SELECT `type` FROM `properties` WHERE `id` = ?", id).on_error([ctx](auto const & err) {
ctx->set_error(
project->db->query_one<int>("SELECT `type` FROM `properties` WHERE `id` = ?", id).on_error([project](auto const & err) {
project->set_error(
fmt::format("failed to fetch unboxed property type: {}", err),
true,
IkarusErrorInfo_Source_SubSystem,
@ -41,16 +38,17 @@ cppbase::Result<IkarusPropertyType, sqlitecpp::SingleQueryError> IkarusProperty:
}
IKA_API void ikarus_property_delete(IkarusProperty * property) {
auto * ctx = property->project->get_function_context();
TRYRV(, property->project->get_db()->execute("DELETE FROM `objects` WHERE `id` = ?", property->id).on_error([ctx](auto const & err) {
ctx->set_error(
fmt::format("failed to delete property from objects table: {}", err),
true,
IkarusErrorInfo_Source_SubSystem,
IkarusErrorInfo_Type_SubSystem_Database
);
}));
TRYRV(
,
property->project->db->execute("DELETE FROM `objects` WHERE `id` = ?", property->id).on_error([property](auto const & err) {
property->project->set_error(
fmt::format("failed to delete property from objects table: {}", err),
true,
IkarusErrorInfo_Source_SubSystem,
IkarusErrorInfo_Type_SubSystem_Database
);
})
);
property->project->uncache(property);
}
@ -60,15 +58,13 @@ IkarusPropertyType ikarus_property_get_type(IkarusProperty const * property) {
}
IkarusPropertySource const * ikarus_property_get_source(IkarusProperty const * property) {
auto * ctx = property->project->get_function_context();
VTRYRV(
auto const source,
nullptr,
property->project->get_db()
property->project->db
->query_one<int>("SELECT `source` FROM `properties` WHERE `id` = ?", property->id)
.on_error([ctx](auto const & err) {
ctx->set_error(
.on_error([property](auto const & err) {
property->project->set_error(
fmt::format("failed to fetch property's source: {}", err),
true,
IkarusErrorInfo_Source_SubSystem,
@ -81,7 +77,7 @@ IkarusPropertySource const * ikarus_property_get_source(IkarusProperty const * p
case IkarusObjectType_Blueprint: return new IkarusPropertySource{property->project->get_blueprint(source)};
case IkarusObjectType_Entity: return new IkarusPropertySource{property->project->get_entity(source)};
default: {
ctx->set_error(
property->project->set_error(
fmt::format("PropertySource is neither blueprint nor entity"),
true,
IkarusErrorInfo_Source_LibIkarus,
@ -94,15 +90,13 @@ IkarusPropertySource const * ikarus_property_get_source(IkarusProperty const * p
}
IkarusValue * ikarus_property_get_default_value(IkarusProperty const * property) {
auto * ctx = property->project->get_function_context();
VTRYRV(
auto const value,
nullptr,
property->project->get_db()
property->project->db
->query_one<int>("SELECT `default_value` FROM `properties` WHERE `id` = ?", property->id)
.on_error([ctx](auto const & err) {
ctx->set_error(
.on_error([property](auto const & err) {
property->project->set_error(
fmt::format("failed to fetch property's default value: {}", err),
true,
IkarusErrorInfo_Source_SubSystem,