From 405afc36e0929d887188be09a5886f79ff0ea1c4 Mon Sep 17 00:00:00 2001 From: gramanas Date: Sat, 22 Sep 2018 12:58:22 +0300 Subject: Standarize error codes --- src/dblayer.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/dblayer.c') diff --git a/src/dblayer.c b/src/dblayer.c index 190cb05..dbd772e 100644 --- a/src/dblayer.c +++ b/src/dblayer.c @@ -356,34 +356,34 @@ int add_get_or_insert_program_to_db(DB *db, const char *name) { return pid; } -int add_transaction_begin(DB *db, const AddOpt * const opt) { +int add_transaction_try(DB *db, const AddOpt * const opt) { __BEGIN_TRANSACTION__ int pid = add_get_or_insert_program_to_db(db, opt->progName); if (db->error == SQL_ERR_SQLITE) { PRINT_ERR("Could not insert program to db.\n"); - return 0; + return 1; } int cid = add_get_or_insert_config_to_db(db, pid, opt->confPath, opt->secret, opt->prime); if (db->error == SQL_ERR_SQLITE) { PRINT_ERR("Could not insert config to db.\n"); - return 0; + return 1; } else if (db->error == SQL_CONFIG_PATH_EXISTS) { PRINT_ERR("This config already exists in the database.\n"); - return 0; + return 1; } else if (db->error == SQL_ERR_PRIMARY_REDEFINITION) { PRINT_ERR("This program already has a primary config.\n"); - return 0; + return 1; } add_insert_relationship(db, pid, cid); if (db->error == SQL_ERR_SQLITE) { PRINT_ERR("rel update failed\n"); - return 0; + return 1; } __END_TRANSACTION__ - return 1; + return 0; } int edit_get_prime_config_from_program(DB *db, char *pName, char *ret, int *secret) { -- cgit v1.2.3