forked from scott/threaded_network_chat
write big ugly panic message for when main() freaks out too much
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
typedef struct __wclient_args_t wclient_args_t;
|
||||
|
||||
void *await_client(void *a);
|
||||
void big_panic_msg(void);
|
||||
void clear_rows(int s, int e);
|
||||
int count_lines(std::string p);
|
||||
int file_disp(std::string p, int lnstart, int lncount = 10);
|
||||
|
||||
32
src/main.cc
32
src/main.cc
@@ -21,7 +21,6 @@ typedef enum { NO_MODE = 0, SERVER_MODE = 1, CLIENT_MODE = 2 } chatmode_t;
|
||||
|
||||
chatmode_t mode = NO_MODE;
|
||||
|
||||
// const int LOG_LENGTH = 10;
|
||||
int line_position = 0;
|
||||
|
||||
struct timeval time_start;
|
||||
@@ -107,10 +106,7 @@ main(int argc, char *argv[])
|
||||
return 0;
|
||||
|
||||
panic_no_mode:
|
||||
fprintf(stderr, "-----FATAL ERROR, THIS SHOULD NEVER HAPPEN-----\n");
|
||||
fprintf(stderr, "You may ask yourself... how do I work this?\n");
|
||||
fprintf(stderr, "And you may find yourself... past the point of return 0;!\n");
|
||||
fprintf(stderr, "And you may ask yourself... well, how did I get here?\n");
|
||||
big_panic_msg();
|
||||
|
||||
if (mode == NO_MODE)
|
||||
fprintf(stderr, "Fatal: Mode was not set!\n");
|
||||
@@ -120,7 +116,31 @@ panic_no_mode:
|
||||
return 1;
|
||||
|
||||
panic_no_server_sock:
|
||||
endwin();
|
||||
big_panic_msg();
|
||||
|
||||
fprintf(stderr, "Fatal: Could not establish server socket!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* For when things go really really bad.
|
||||
* Check if there is a window and if so, close it.
|
||||
* Spit out a really loud obnoxious error afterwards.
|
||||
*/
|
||||
void
|
||||
big_panic_msg(void)
|
||||
{
|
||||
if (!isendwin())
|
||||
endwin();
|
||||
|
||||
fprintf(stderr, "-----FATAL ERROR, THIS SHOULD NEVER HAPPEN-----\n");
|
||||
usleep(400 * 1000);
|
||||
fprintf(stderr, "You may ask yourself... how do I work this?\n");
|
||||
putchar(7);
|
||||
usleep(400 * 1000);
|
||||
fprintf(stderr, "And you may find yourself... past the point of return 0;!\n");
|
||||
putchar(7);
|
||||
usleep(400 * 1000);
|
||||
fprintf(stderr, "And you may ask yourself... well, how did I get here?\n");
|
||||
putchar(7);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user