Improved error messages.

This commit is contained in:
wb2osz 2023-05-14 23:25:02 +01:00
parent 92a2097d30
commit f8b9cae461
2 changed files with 20 additions and 9 deletions

View File

@ -709,6 +709,14 @@ static char *split (char *string, int rest_of_line)
* *
*--------------------------------------------------------------------*/ *--------------------------------------------------------------------*/
static void rtfm()
{
text_color_set(DW_COLOR_ERROR);
dw_printf ("See online documentation:\n");
dw_printf (" stable release: https://github.com/wb2osz/direwolf/tree/master/doc\n");
dw_printf (" development version: https://github.com/wb2osz/direwolf/tree/dev/doc\n");
dw_printf (" additional topics: https://github.com/wb2osz/direwolf-doc\n");
}
void config_init (char *fname, struct audio_s *p_audio_config, void config_init (char *fname, struct audio_s *p_audio_config,
struct digi_config_s *p_digi_config, struct digi_config_s *p_digi_config,
@ -970,7 +978,8 @@ void config_init (char *fname, struct audio_s *p_audio_config,
text_color_set(DW_COLOR_ERROR); text_color_set(DW_COLOR_ERROR);
dw_printf ("ERROR - Could not open config file %s\n", filepath); dw_printf ("ERROR - Could not open config file %s\n", filepath);
dw_printf ("Try using -c command line option for alternate location.\n"); dw_printf ("Try using -c command line option for alternate location.\n");
return; rtfm();
exit(EXIT_FAILURE);
} }
dw_printf ("\nReading config file %s\n", filepath); dw_printf ("\nReading config file %s\n", filepath);
@ -1027,7 +1036,8 @@ void config_init (char *fname, struct audio_s *p_audio_config,
if (t == NULL) { if (t == NULL) {
text_color_set(DW_COLOR_ERROR); text_color_set(DW_COLOR_ERROR);
dw_printf ("Config file: Missing name of audio device for ADEVICE command on line %d.\n", line); dw_printf ("Config file: Missing name of audio device for ADEVICE command on line %d.\n", line);
continue; rtfm();
exit(EXIT_FAILURE);
} }
p_audio_config->adev[adevice].defined = 1; p_audio_config->adev[adevice].defined = 1;
@ -1986,7 +1996,7 @@ void config_init (char *fname, struct audio_s *p_audio_config,
dw_printf ("Config file line %d: %s with CM108 is only available when USB Audio GPIO support is enabled.\n", line, otname); dw_printf ("Config file line %d: %s with CM108 is only available when USB Audio GPIO support is enabled.\n", line, otname);
dw_printf ("You must rebuild direwolf with CM108 Audio Adapter GPIO PTT support.\n"); dw_printf ("You must rebuild direwolf with CM108 Audio Adapter GPIO PTT support.\n");
dw_printf ("See Interface Guide for details.\n"); dw_printf ("See Interface Guide for details.\n");
rtfm();
exit (EXIT_FAILURE); exit (EXIT_FAILURE);
#endif #endif
} }

View File

@ -138,7 +138,7 @@ static BOOL cleanup_win (int);
static void cleanup_linux (int); static void cleanup_linux (int);
#endif #endif
static void usage (char **argv); static void usage ();
#if defined(__SSE__) && !defined(__APPLE__) #if defined(__SSE__) && !defined(__APPLE__)
@ -598,7 +598,7 @@ int main (int argc, char *argv[])
case '?': case '?':
/* For '?' unknown option message was already printed. */ /* For '?' unknown option message was already printed. */
usage (argv); usage ();
break; break;
case 'd': /* Set debug option. */ case 'd': /* Set debug option. */
@ -742,7 +742,7 @@ int main (int argc, char *argv[])
/* Should not be here. */ /* Should not be here. */
text_color_set(DW_COLOR_DEBUG); text_color_set(DW_COLOR_DEBUG);
dw_printf("?? getopt returned character code 0%o ??\n", c); dw_printf("?? getopt returned character code 0%o ??\n", c);
usage (argv); usage ();
} }
} /* end while(1) for options */ } /* end while(1) for options */
@ -987,6 +987,7 @@ int main (int argc, char *argv[])
text_color_set(DW_COLOR_ERROR); text_color_set(DW_COLOR_ERROR);
dw_printf ("Pointless to continue without audio device.\n"); dw_printf ("Pointless to continue without audio device.\n");
SLEEP_SEC(5); SLEEP_SEC(5);
usage ();
exit (1); exit (1);
} }
@ -1722,16 +1723,16 @@ static void usage (char **argv)
dw_printf ("\n"); dw_printf ("\n");
#if __WIN32__ #if __WIN32__
dw_printf ("Complete documentation can be found in the 'doc' folder\n"); dw_printf ("Documentation can be found in the 'doc' folder\n");
#else #else
// TODO: Could vary by platform and build options. // TODO: Could vary by platform and build options.
dw_printf ("Complete documentation can be found in /usr/local/share/doc/direwolf\n"); dw_printf ("Documentation can be found in /usr/local/share/doc/direwolf\n");
#endif #endif
dw_printf ("or online at https://github.com/wb2osz/direwolf/tree/master/doc\n"); dw_printf ("or online at https://github.com/wb2osz/direwolf/tree/master/doc\n");
dw_printf ("additional topics: https://github.com/wb2osz/direwolf-doc\n");
text_color_set(DW_COLOR_INFO); text_color_set(DW_COLOR_INFO);
exit (EXIT_FAILURE); exit (EXIT_FAILURE);
} }
/* end direwolf.c */ /* end direwolf.c */