@@ -127,7 +127,7 @@ SQLite::~SQLite() {
127
127
128
128
bool SQLite::open_db () {
129
129
if (db) {
130
- UtilityFunctions::printerr (" GDSQLite Error: Can't open database if connection is already open!" );
130
+ UtilityFunctions::push_error (" GDSQLite Error: Can't open database if connection is already open!" );
131
131
return false ;
132
132
}
133
133
@@ -157,7 +157,7 @@ bool SQLite::open_db() {
157
157
sqlite3_vfs_register (gdsqlite_vfs (), 0 );
158
158
rc = sqlite3_open_v2 (char_path, &db, SQLITE_OPEN_READONLY, " godot" );
159
159
} else {
160
- UtilityFunctions::printerr (" GDSQLite Error: Opening in-memory databases in read-only mode is currently not supported!" );
160
+ UtilityFunctions::push_error (" GDSQLite Error: Opening in-memory databases in read-only mode is currently not supported!" );
161
161
return false ;
162
162
}
163
163
} else {
@@ -168,7 +168,7 @@ bool SQLite::open_db() {
168
168
}
169
169
170
170
if (rc != SQLITE_OK) {
171
- UtilityFunctions::printerr (" GDSQLite Error: Can't open database: " + String::utf8 (sqlite3_errmsg (db)));
171
+ UtilityFunctions::push_error (" GDSQLite Error: Can't open database: " + String::utf8 (sqlite3_errmsg (db)));
172
172
return false ;
173
173
} else if (verbosity_level > VerbosityLevel::QUIET) {
174
174
UtilityFunctions::print (" Opened database successfully (" + path + " )" );
@@ -178,7 +178,7 @@ bool SQLite::open_db() {
178
178
if (foreign_keys) {
179
179
rc = sqlite3_exec (db, " PRAGMA foreign_keys=on;" , NULL , NULL , &zErrMsg);
180
180
if (rc != SQLITE_OK) {
181
- UtilityFunctions::printerr (" GDSQLite Error: Can't enable foreign keys: " + String::utf8 (zErrMsg));
181
+ UtilityFunctions::push_error (" GDSQLite Error: Can't enable foreign keys: " + String::utf8 (zErrMsg));
182
182
sqlite3_free (zErrMsg);
183
183
return false ;
184
184
}
@@ -191,7 +191,7 @@ bool SQLite::close_db() {
191
191
if (db) {
192
192
// Cannot close database!
193
193
if (sqlite3_close_v2 (db) != SQLITE_OK) {
194
- UtilityFunctions::printerr (" GDSQLite Error: Can't close database!" );
194
+ UtilityFunctions::push_error (" GDSQLite Error: Can't close database!" );
195
195
return false ;
196
196
} else {
197
197
db = nullptr ;
@@ -202,7 +202,7 @@ bool SQLite::close_db() {
202
202
}
203
203
}
204
204
205
- UtilityFunctions::printerr (" GDSQLite Error: Can't close database if connection is not open!" );
205
+ UtilityFunctions::push_error (" GDSQLite Error: Can't close database if connection is not open!" );
206
206
return false ;
207
207
}
208
208
@@ -231,15 +231,15 @@ bool SQLite::query_with_bindings(const String &p_query, Array param_bindings) {
231
231
zErrMsg = sqlite3_errmsg (db);
232
232
error_message = String::utf8 (zErrMsg);
233
233
if (rc != SQLITE_OK) {
234
- UtilityFunctions::printerr (" --> SQL error: " + error_message);
234
+ UtilityFunctions::push_error (" --> SQL error: " + error_message);
235
235
sqlite3_finalize (stmt);
236
236
return false ;
237
237
}
238
238
239
239
/* Check if the param_bindings size exceeds the required parameter count */
240
240
int parameter_count = sqlite3_bind_parameter_count (stmt);
241
241
if (param_bindings.size () < parameter_count) {
242
- UtilityFunctions::printerr (" GDSQLite Error: Insufficient number of parameters to satisfy required number of bindings in statement!" );
242
+ UtilityFunctions::push_error (" GDSQLite Error: Insufficient number of parameters to satisfy required number of bindings in statement!" );
243
243
sqlite3_finalize (stmt);
244
244
return false ;
245
245
}
@@ -284,7 +284,7 @@ bool SQLite::query_with_bindings(const String &p_query, Array param_bindings) {
284
284
}
285
285
286
286
default :
287
- UtilityFunctions::printerr (" GDSQLite Error: Binding a parameter of type " + String (std::to_string (binding_value.get_type ()).c_str ()) + " (TYPE_*) is not supported!" );
287
+ UtilityFunctions::push_error (" GDSQLite Error: Binding a parameter of type " + String (std::to_string (binding_value.get_type ()).c_str ()) + " (TYPE_*) is not supported!" );
288
288
sqlite3_finalize (stmt);
289
289
return false ;
290
290
}
@@ -348,7 +348,7 @@ bool SQLite::query_with_bindings(const String &p_query, Array param_bindings) {
348
348
zErrMsg = sqlite3_errmsg (db);
349
349
error_message = String::utf8 (zErrMsg);
350
350
if (rc != SQLITE_OK) {
351
- UtilityFunctions::printerr (" --> SQL error: " + error_message);
351
+ UtilityFunctions::push_error (" --> SQL error: " + error_message);
352
352
return false ;
353
353
} else if (verbosity_level > VerbosityLevel::NORMAL) {
354
354
UtilityFunctions::print (" --> Query succeeded" );
@@ -471,18 +471,18 @@ bool SQLite::validate_table_dict(const Dictionary &p_table_dict) {
471
471
int64_t number_of_columns = columns.size ();
472
472
for (int64_t i = 0 ; i <= number_of_columns - 1 ; i++) {
473
473
if (p_table_dict[columns[i]].get_type () != Variant::DICTIONARY) {
474
- UtilityFunctions::printerr (" GDSQLite Error: All values of the table dictionary should be of type Dictionary" );
474
+ UtilityFunctions::push_error (" GDSQLite Error: All values of the table dictionary should be of type Dictionary" );
475
475
return false ;
476
476
}
477
477
478
478
column_dict = p_table_dict[columns[i]];
479
479
if (!column_dict.has (" data_type" )) {
480
- UtilityFunctions::printerr (" GDSQLite Error: The field \" data_type\" is a required part of the table dictionary" );
480
+ UtilityFunctions::push_error (" GDSQLite Error: The field \" data_type\" is a required part of the table dictionary" );
481
481
return false ;
482
482
}
483
483
484
484
if (column_dict[" data_type" ].get_type () != Variant::STRING) {
485
- UtilityFunctions::printerr (" GDSQLite Error: The field \" data_type\" should be of type String" );
485
+ UtilityFunctions::push_error (" GDSQLite Error: The field \" data_type\" should be of type String" );
486
486
return false ;
487
487
}
488
488
@@ -504,7 +504,7 @@ bool SQLite::validate_table_dict(const Dictionary &p_table_dict) {
504
504
}
505
505
506
506
if (data_type_type != default_type) {
507
- UtilityFunctions::printerr (" GDSQLite Error: The type of the field \" default\" ( " + String (std::to_string (default_type).c_str ()) + " ) should be the same type as the \" datatype\" -field ( " + String (std::to_string (data_type_type).c_str ()) + " )" );
507
+ UtilityFunctions::push_error (" GDSQLite Error: The type of the field \" default\" ( " + String (std::to_string (default_type).c_str ()) + " ) should be the same type as the \" datatype\" -field ( " + String (std::to_string (data_type_type).c_str ()) + " )" );
508
508
return false ;
509
509
}
510
510
}
@@ -588,7 +588,7 @@ bool SQLite::insert_rows(const String &p_name, const Array &p_row_array) {
588
588
int64_t number_of_rows = p_row_array.size ();
589
589
for (int64_t i = 0 ; i <= number_of_rows - 1 ; i++) {
590
590
if (p_row_array[i].get_type () != Variant::DICTIONARY) {
591
- UtilityFunctions::printerr (" GDSQLite Error: All elements of the Array should be of type Dictionary" );
591
+ UtilityFunctions::push_error (" GDSQLite Error: All elements of the Array should be of type Dictionary" );
592
592
/* Don't forget to close the transaction! */
593
593
/* Maybe we should do a rollback instead? */
594
594
query (" END TRANSACTION;" );
@@ -615,7 +615,7 @@ Array SQLite::select_rows(const String &p_name, const String &p_conditions, cons
615
615
int64_t number_of_columns = p_columns_array.size ();
616
616
for (int64_t i = 0 ; i <= number_of_columns - 1 ; i++) {
617
617
if (p_columns_array[i].get_type () != Variant::STRING) {
618
- UtilityFunctions::printerr (" GDSQLite Error: All elements of the Array should be of type String" );
618
+ UtilityFunctions::push_error (" GDSQLite Error: All elements of the Array should be of type String" );
619
619
return query_result;
620
620
}
621
621
query_string += (const String &)p_columns_array[i];
@@ -692,7 +692,7 @@ static void function_callback(sqlite3_context *context, int argc, sqlite3_value
692
692
693
693
/* Check if the callable is valid */
694
694
if (!callable.is_valid ()) {
695
- UtilityFunctions::printerr (" GDSQLite Error: Supplied function reference is invalid! Aborting callback..." );
695
+ UtilityFunctions::push_error (" GDSQLite Error: Supplied function reference is invalid! Aborting callback..." );
696
696
return ;
697
697
}
698
698
@@ -793,7 +793,7 @@ bool SQLite::create_function(const String &p_name, const Callable &p_callable, i
793
793
/* Create the actual function */
794
794
rc = sqlite3_create_function (db, zFunctionName, nArg, eTextRep, pApp, xFunc, xStep, xFinal);
795
795
if (rc) {
796
- UtilityFunctions::printerr (" GDSQLite Error: " + String (sqlite3_errmsg (db)));
796
+ UtilityFunctions::push_error (" GDSQLite Error: " + String (sqlite3_errmsg (db)));
797
797
return false ;
798
798
} else if (verbosity_level > VerbosityLevel::NORMAL) {
799
799
UtilityFunctions::print (" Succesfully added function \" " + p_name + " \" to function registry" );
@@ -816,7 +816,7 @@ bool SQLite::import_from_json(String import_path) {
816
816
/* Open the json-file and stream its content into a stringstream */
817
817
std::ifstream ifs (char_path);
818
818
if (ifs.fail ()) {
819
- UtilityFunctions::printerr (" GDSQLite Error: Failed to open specified json-file (" + import_path + " )" );
819
+ UtilityFunctions::push_error (" GDSQLite Error: Failed to open specified json-file (" + import_path + " )" );
820
820
return false ;
821
821
}
822
822
std::stringstream buffer;
@@ -832,7 +832,7 @@ bool SQLite::import_from_json(String import_path) {
832
832
if (error != Error::OK) {
833
833
/* Throw a parsing error */
834
834
// TODO: Figure out how to cast a int32_t to a Godot String using the new API
835
- UtilityFunctions::printerr (" GDSQLite Error: parsing failed! reason: " + json->get_error_message () + " , at line: ???" );
835
+ UtilityFunctions::push_error (" GDSQLite Error: parsing failed! reason: " + json->get_error_message () + " , at line: ???" );
836
836
// GODOT_LOG(2, "GDSQLite Error: parsing failed! reason: " + result->get_error_string() + ", at line: " + String::num_int64(result->get_error_line()))
837
837
return false ;
838
838
}
@@ -906,7 +906,7 @@ bool SQLite::import_from_json(String import_path) {
906
906
int64_t number_of_rows = object.row_array .size ();
907
907
for (int64_t i = 0 ; i <= number_of_rows - 1 ; i++) {
908
908
if (object.row_array [i].get_type () != Variant::DICTIONARY) {
909
- UtilityFunctions::printerr (" GDSQLite Error: All elements of the Array should be of type Dictionary" );
909
+ UtilityFunctions::push_error (" GDSQLite Error: All elements of the Array should be of type Dictionary" );
910
910
return false ;
911
911
}
912
912
if (!insert_row (object.name , object.row_array [i])) {
@@ -991,7 +991,7 @@ bool SQLite::export_to_json(String export_path) {
991
991
992
992
std::ofstream ofs (char_path, std::ios::trunc );
993
993
if (ofs.fail ()) {
994
- UtilityFunctions::printerr (" GDSQLite Error: Can't open specified json-file, file does not exist or is locked" );
994
+ UtilityFunctions::push_error (" GDSQLite Error: Can't open specified json-file, file does not exist or is locked" );
995
995
return false ;
996
996
}
997
997
Ref<JSON> json;
@@ -1016,22 +1016,22 @@ bool SQLite::validate_json(const Array &database_array, std::vector<object_struc
1016
1016
/* Get the name of the object */
1017
1017
if (!temp_dict.has (" name" )) {
1018
1018
/* Did not find the necessary key! */
1019
- UtilityFunctions::printerr (" GDSQlite Error: Did not find required key \" name\" in the supplied json-file" );
1019
+ UtilityFunctions::push_error (" GDSQlite Error: Did not find required key \" name\" in the supplied json-file" );
1020
1020
return false ;
1021
1021
}
1022
1022
new_object.name = temp_dict[" name" ];
1023
1023
1024
1024
/* Extract the sql template for generating the object */
1025
1025
if (!temp_dict.has (" sql" )) {
1026
1026
/* Did not find the necessary key! */
1027
- UtilityFunctions::printerr (" GDSQlite Error: Did not find required key \" sql\" in the supplied json-file" );
1027
+ UtilityFunctions::push_error (" GDSQlite Error: Did not find required key \" sql\" in the supplied json-file" );
1028
1028
return false ;
1029
1029
}
1030
1030
new_object.sql = temp_dict[" sql" ];
1031
1031
1032
1032
if (!temp_dict.has (" type" )) {
1033
1033
/* Did not find the necessary key! */
1034
- UtilityFunctions::printerr (" GDSQlite Error: Did not find required key \" type\" in the supplied json-file" );
1034
+ UtilityFunctions::push_error (" GDSQlite Error: Did not find required key \" type\" in the supplied json-file" );
1035
1035
return false ;
1036
1036
}
1037
1037
if (temp_dict[" type" ] == String (" table" )) {
@@ -1042,18 +1042,18 @@ bool SQLite::validate_json(const Array &database_array, std::vector<object_struc
1042
1042
1043
1043
if (!temp_dict.has (" row_array" )) {
1044
1044
/* Did not find the necessary key! */
1045
- UtilityFunctions::printerr (" GDSQlite Error: Did not find required key \" row_array\" in the supplied json-file" );
1045
+ UtilityFunctions::push_error (" GDSQlite Error: Did not find required key \" row_array\" in the supplied json-file" );
1046
1046
return false ;
1047
1047
} else if (Variant (temp_dict[" row_array" ]).get_type () != Variant::ARRAY) {
1048
- UtilityFunctions::printerr (" GDSQlite Error: The value of the key \" row_array\" should consist of an array of rows" );
1048
+ UtilityFunctions::push_error (" GDSQlite Error: The value of the key \" row_array\" should consist of an array of rows" );
1049
1049
return false ;
1050
1050
}
1051
1051
new_object.row_array = temp_dict[" row_array" ];
1052
1052
} else if (temp_dict[" type" ] == String (" trigger" )) {
1053
1053
new_object.type = TRIGGER;
1054
1054
} else {
1055
1055
/* Did not find the necessary key! */
1056
- UtilityFunctions::printerr (2 , " GDSQlite Error: The value of key \" type\" is restricted to either \" table\" or \" trigger\" " );
1056
+ UtilityFunctions::push_error (2 , " GDSQlite Error: The value of key \" type\" is restricted to either \" table\" or \" trigger\" " );
1057
1057
return false ;
1058
1058
}
1059
1059
@@ -1198,7 +1198,7 @@ int SQLite::enable_load_extension(const bool &p_onoff) {
1198
1198
rc = sqlite3_enable_load_extension (db, 0 );
1199
1199
}
1200
1200
if (rc != SQLITE_OK) {
1201
- UtilityFunctions::printerr (" GDSQLite Error: Extension loading cannot be enabled/disabled." );
1201
+ UtilityFunctions::push_error (" GDSQLite Error: Extension loading cannot be enabled/disabled." );
1202
1202
}
1203
1203
return rc;
1204
1204
}
@@ -1222,7 +1222,7 @@ int SQLite::load_extension(const String &p_path, const String &entrypoint) {
1222
1222
sqlite3_db_config (db, SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION, 0 , NULL );
1223
1223
1224
1224
if (rc != SQLITE_OK) {
1225
- UtilityFunctions::printerr (" GDSQLite Error: Unable to load extension: " + String::utf8 (zErrMsg));
1225
+ UtilityFunctions::push_error (" GDSQLite Error: Unable to load extension: " + String::utf8 (zErrMsg));
1226
1226
sqlite3_free (zErrMsg);
1227
1227
return rc;
1228
1228
}
0 commit comments