Ejemplo n.º 1
0
/**
 *	Output the exception if it has not occurred before, otherwise only
 *	output the exception if the minimum period has elapsed since the
 *	last outputting of this exception.
 *
 *	@param ne 		the NubException
 *	@param prefix 	any prefix to add to the error message, or NULL if no prefix
 *  @param suffix 	any prefix to add to the error message, or NULL if no suffix
 *
 */
void ErrorReporter::reportException(const NetworkException & ne, const char* prefix, const char* suffix)
{
	Address offender(0, 0);
	ne.getAddress(offender);

	if (prefix)
	{
		if (!suffix)
		{
			this->reportError(offender,
				"%s: Exception occurred: %s",
				prefix, reasonToString(ne.reason()));
		}
		else
		{
			this->reportError(offender,
				"%s: Exception occurred: %s %s",
				prefix, reasonToString(ne.reason()), suffix);
		}
	}
	else
	{
		if (!suffix)
		{
			this->reportError(offender, "Exception occurred: %s",
				reasonToString(ne.reason()));
		}
		else
		{
			this->reportError(offender, "Exception occurred: %s %s",
				reasonToString(ne.reason()), suffix);
		}
	}
}
Ejemplo n.º 2
0
 std::string getMessage() const { return reasonToString(reason_); }
Ejemplo n.º 3
0
int main (int argc, char **argv)
{
	int c;
	int timeInSecs;
	int retval = 0;

	if (argc < 2) {
		showHelp(argv[0]);		// show help info and exit
		exit(-1);
	}

	while (1)
	{
		int option_index = 0;
		c = getopt_long(argc, argv, "ghqSt:v",
			       	long_options, &option_index);

		if (c == -1) // end of the options.
			break;

		switch (c)
		{
			case 0:
				break;

			case 'g':
				timeInSecs = getTimeout();
				if (!quiet_flag)
					printf(
					"Timeout is %d seconds\n",
					timeInSecs);
				retval = timeInSecs;
				break;

			case 'h':
				showHelp(argv[0]);  // show help info and exit
				break;

			case 's':
				shutdown();
				break;

			case 'S':
				retval = status();
				if (!quiet_flag) {
					printf("Status = %s (%d)\n",
						reasonToString(retval), retval);
				}
				break;

			case 't':
				timeInSecs = atoi(optarg);
				setTimeout(timeInSecs);
				timeInSecs = getTimeout();
				if (!quiet_flag)
					printf(
					"Timeout is %d Seconds\n",
					timeInSecs);
				break;

			default:
				showHelp(argv[0]);
				exit(-1);
		}
	}
	return(retval);
}