about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--pcoin.cpp26
-rw-r--r--tcoin.cpp29
2 files changed, 35 insertions, 20 deletions
diff --git a/pcoin.cpp b/pcoin.cpp
index 7a15fff..4919ac7 100644
--- a/pcoin.cpp
+++ b/pcoin.cpp
@@ -70,6 +70,12 @@
 #define ERR_ADD_FILE_VALUE_INSUFFICIENT_FUNDS 1
 #define ERR_ADD_FILE_VALUE_FATAL 999
 #define ERR_IN_GET_INTERNAL_TOTAL_OWED_SELF_PROGRAM_DOESNT_EXIST -1
+#define ERR_GET_FILE_VALUE_COULDNT_OPEN_BASEFILE 1
+#define ERR_ADD_FILE_VALUE_COULDNT_OPEN_BASEFILE 1
+#define ERR_SEND_MESSAGE_RECEIVER_MSG_FILE_UNABLE_TO_BE_UPDATED_FATAL 101
+#define ERR_SEND_MESSAGE_PROGRAM_RECEIVER_MSG_FILE_UNABLE_TO_BE_UPDATED_FATAL 103
+#define ERR_SEND_MESSAGE_SENDER_MSG_FILE_UNABLE_TO_BE_UPDATED_FATAL 102
+#define ERR_SEND_MESSAGE_SENDER_PROGRAM_MSG_FILE_UNABLE_TO_BE_UPDATED_FATAL 104
 
 #define ERR_KEY_NOT_IN_USE 9
 #define ERR_NO_ARGS 8
@@ -229,7 +235,7 @@ long long int get_file_value(const char* file_name)
     if(!strcmp(file_name, "base/base"))
     {
       std::cerr << "\nError! Could not open file at " << file_path << "!\n\n";
-      exit_program(1);
+      exit_program(ERR_GET_FILE_VALUE_COULDNT_OPEN_BASEFILE);
     }
     else {
       std::cerr << "\nError! Could not open file at " << file_path << "! Assuming its internal content is \"0\\n\".\n\n";
@@ -265,7 +271,7 @@ int add_file_value(const char* file_name, const long long int &value_to_add, con
       file.close();
       delete[] file_path;
       delete[] temp_file_path;
-      exit_program(1);
+      exit_program(ERR_ADD_FILE_VALUE_COULDNT_OPEN_BASEFILE);
     }
   }
 
@@ -721,8 +727,8 @@ int send_message(const char* sender_username, const char* receiver_username, con
 
       if(!fout) //error
       {
-        std::cerr << "Fatal error 101: the receiver message file was unable to be updated. Please contact login@tilde.town (town-only) or login@tilde.team (internet-wide to report this error (because it requires manual recovery).";
-        exit_program(101);
+        std::cerr << "Fatal error " << ERR_SEND_MESSAGE_RECEIVER_MSG_FILE_UNABLE_TO_BE_UPDATED_FATAL << ": the receiver message file was unable to be updated. Please contact login@tilde.town (town-only) or login@tilde.team (internet-wide to report this error (because it requires manual recovery).";
+        exit_program(ERR_SEND_MESSAGE_RECEIVER_MSG_FILE_UNABLE_TO_BE_UPDATED_FATAL);
       }
       else
       {
@@ -810,8 +816,8 @@ int send_message(const char* sender_username, const char* receiver_username, con
 
             if(!fout) //error
             {
-              std::cerr << "Fatal error 103: the receiver program_message file was unable to be updated. Please contact login@tilde.town (town-only) or login@tilde.team (internet-wide to report this error (because it requires manual recovery).";
-              exit_program(103);
+              std::cerr << "Fatal error " << ERR_SEND_MESSAGE_PROGRAM_RECEIVER_MSG_FILE_UNABLE_TO_BE_UPDATED_FATAL << ": the receiver program_message file was unable to be updated. Please contact login@tilde.town (town-only) or login@tilde.team (internet-wide to report this error (because it requires manual recovery).";
+              exit_program(ERR_SEND_MESSAGE_PROGRAM_RECEIVER_MSG_FILE_UNABLE_TO_BE_UPDATED_FATAL);
             }
             else
             {
@@ -905,8 +911,8 @@ int send_message(const char* sender_username, const char* receiver_username, con
 
           if(!fout) //error
           {
-            std::cerr << "Fatal error 102: the sender message file was unable to be updated. Please contact login@tilde.town (town-only) or login@tilde.team (internet-wide to report this error (because it requires manual recovery).";
-            exit_program(102);
+            std::cerr << "Fatal error " << ERR_SEND_MESSAGE_SENDER_MSG_FILE_UNABLE_TO_BE_UPDATED_FATAL << ": the sender message file was unable to be updated. Please contact login@tilde.town (town-only) or login@tilde.team (internet-wide to report this error (because it requires manual recovery).";
+            exit_program(ERR_SEND_MESSAGE_SENDER_MSG_FILE_UNABLE_TO_BE_UPDATED_FATAL);
           }
           else
           {
@@ -991,8 +997,8 @@ int send_message(const char* sender_username, const char* receiver_username, con
 
                 if(!fout) //error
                 {
-                  std::cerr << "Fatal error 104: the sender program message file was unable to be updated. Please contact login@tilde.town (town-only) or login@tilde.team (internet-wide to report this error (because it requires manual recovery).";
-                  exit_program(104);
+                  std::cerr << "Fatal error " << ERR_SEND_MESSAGE_SENDER_PROGRAM_MSG_FILE_UNABLE_TO_BE_UPDATED_FATAL << ": the sender program message file was unable to be updated. Please contact login@tilde.town (town-only) or login@tilde.team (internet-wide to report this error (because it requires manual recovery).";
+                  exit_program(ERR_SEND_MESSAGE_SENDER_PROGRAM_MSG_FILE_UNABLE_TO_BE_UPDATED_FATAL);
                 }
                 else
                 {
diff --git a/tcoin.cpp b/tcoin.cpp
index 393a2bb..2010af1 100644
--- a/tcoin.cpp
+++ b/tcoin.cpp
@@ -66,6 +66,15 @@
 #define ERR_NEGATIVE_SEND_AMOUNT 2
 #define ERR_INSUFFICIENT_FUNDS 3
 #define ERR_RECEIVER_NOT_FOUND 1
+#define ERR_GET_FILE_VALUE_COULDNT_OPEN_BASEFILE 1
+#define ERR_ADD_FILE_VALUE_COULDNT_OPEN_BASEFILE 1
+#define ERR_ADD_FILE_VALUE_FATAL 999
+#define ERR_GET_FILE_VALUE_COULDNT_OPEN_BASEFILE 1
+#define ERR_ADD_FILE_VALUE_COULDNT_OPEN_BASEFILE 1
+#define ERR_SEND_MESSAGE_RECEIVER_MSG_FILE_UNABLE_TO_BE_UPDATED_FATAL 101
+#define ERR_SEND_MESSAGE_PROGRAM_RECEIVER_MSG_FILE_UNABLE_TO_BE_UPDATED_FATAL 103
+#define ERR_SEND_MESSAGE_SENDER_MSG_FILE_UNABLE_TO_BE_UPDATED_FATAL 102
+
 
 void exit_program(const int error_number)
 {
@@ -213,7 +222,7 @@ long long int get_file_value(const char* file_name)
     if(!strcmp(file_name, "base/base"))
     {
       std::cerr << "\nError! Could not open file at " << file_path << "!\n\n";
-      exit_program(1);
+      exit_program(ERR_GET_FILE_VALUE_COULDNT_OPEN_BASEFILE);
     }
     else
     {
@@ -251,7 +260,7 @@ int add_file_value(const char* file_name, const long long int &value_to_add, con
       file.close();
       delete[] file_path;
       delete[] temp_file_path;
-      exit_program(1);
+      exit_program(ERR_ADD_FILE_VALUE_COULDNT_OPEN_BASEFILE);
     }
   }
 
@@ -281,8 +290,8 @@ int add_file_value(const char* file_name, const long long int &value_to_add, con
 
   if(!file2) //error
   {
-    std::cerr << "Fatal error 999: the file \"" << file_name << "\" was unable to be updated. Please contact login@tilde.town (town-only) or login@tilde.team (internet-wide to report this error (because it requires manual recovery).";
-    exit_program(999);
+    std::cerr << "Fatal error " << ERR_ADD_FILE_VALUE_FATAL << ": the file \"" << file_name << "\" was unable to be updated. Please contact login@tilde.town (town-only) or login@tilde.team (internet-wide to report this error (because it requires manual recovery).";
+    exit_program(ERR_ADD_FILE_VALUE_FATAL);
   }
   else
   {
@@ -993,8 +1002,8 @@ int send_message(const char* sender_username, const char* receiver_username, con
 
       if(!fout) //error
       {
-        std::cerr << "Fatal error 101: the receiver message file was unable to be updated. Please contact login@tilde.town (town-only) or login@tilde.team (internet-wide to report this error (because it requires manual recovery).";
-        exit_program(101);
+        std::cerr << "Fatal error" << ERR_SEND_MESSAGE_RECEIVER_MSG_FILE_UNABLE_TO_BE_UPDATED_FATAL << ": the receiver message file was unable to be updated. Please contact login@tilde.town (town-only) or login@tilde.team (internet-wide to report this error (because it requires manual recovery).";
+        exit_program(ERR_SEND_MESSAGE_RECEIVER_MSG_FILE_UNABLE_TO_BE_UPDATED_FATAL);
       }
       else
       {
@@ -1082,8 +1091,8 @@ int send_message(const char* sender_username, const char* receiver_username, con
 
             if(!fout) //error
             {
-              std::cerr << "Fatal error 103: the receiver program_message file was unable to be updated. Please contact login@tilde.town (town-only) or login@tilde.team (internet-wide to report this error (because it requires manual recovery).";
-              exit_program(103);
+              std::cerr << "Fatal error " << ERR_SEND_MESSAGE_PROGRAM_RECEIVER_MSG_FILE_UNABLE_TO_BE_UPDATED_FATAL << ": the receiver program_message file was unable to be updated. Please contact login@tilde.town (town-only) or login@tilde.team (internet-wide to report this error (because it requires manual recovery).";
+              exit_program(ERR_SEND_MESSAGE_PROGRAM_RECEIVER_MSG_FILE_UNABLE_TO_BE_UPDATED_FATAL);
             }
             else
             {
@@ -1176,8 +1185,8 @@ int send_message(const char* sender_username, const char* receiver_username, con
 
           if(!fout) //error
           {
-            std::cerr << "Fatal error 102: the sender message file was unable to be updated. Please contact login@tilde.town (town-only) or login@tilde.team (internet-wide to report this error (because it requires manual recovery).";
-            exit_program(102);
+            std::cerr << "Fatal error " << ERR_SEND_MESSAGE_SENDER_MSG_FILE_UNABLE_TO_BE_UPDATED_FATAL << ": the sender message file was unable to be updated. Please contact login@tilde.town (town-only) or login@tilde.team (internet-wide to report this error (because it requires manual recovery).";
+            exit_program(ERR_SEND_MESSAGE_SENDER_MSG_FILE_UNABLE_TO_BE_UPDATED_FATAL);
           }
           else
           {