Esempio n. 1
0
void active_server_setException(ACTIVE_SERVER *self, EXCEPTION *e) {
	assert(self);
	assert(e);

	if (ERR) {
		exception_delCallback(ERR);
		exception_free(ERR);
		ERR = NULL;
	}

	ERR = e;
	self->exception_internal = FALSE;
}
Esempio n. 2
0
void exception_throw(EXCEPTION *self) {
	assert(self);

	if (exception_exists(self)) {
		if (exception_isCallback(self)) {
			exception_throwCallback(self);
		} else {
			exception_show(self);
			exception_free(self);
			exit(EXIT_FAILURE);
		}
	}
}
Esempio n. 3
0
exception_t* exception_catch(exception_t* exception) {
	// Check that the exception is non-NULL.
	if ( exception == NULL ) {
		fprintf(stderr, "exception_catch failed: exception_t is NULL.\n");
		fflush(stderr);
		exit(-1);
	}

	// Print the exception message.
	exception_print(exception);

	// Free the exception and return NULL (see: exception_free()).
	return exception_free(exception);
}
Esempio n. 4
0
void active_server_free(ACTIVE_SERVER *self) {
	assert(self);

	network_free(NET);

	if (ERR && self->exception_internal) {
		exception_delCallback(ERR);
		exception_free(ERR);
	}

	if (self->root) {
		free(self->root);
		self->root = NULL;
	}

	free(self);
	self = NULL;
}
Esempio n. 5
0
int main(void) {
	EXCEPTION *e = exception_new();

	printf ( "NEW\n" );
	DATABASE *db = database_new();
	database_setException(db, e);
	exception_throw(e);

	printf ( "PARAM\n" );
	database_setHost(db, "localhost");
	database_setName(db, "template1");
	database_setUser(db, "postgres");
	database_setPassword(db, "postgres");

	printf ( "OPEN\n" );
	database_open(db);
	exception_throw(e);

	printf ( "VERSION" );
	char *ver = database_getVersion(db);
	exception_throw(e);
	printf ( " (%s)\n", ver );
	free(ver);

	printf ( "RANDOM" );
	int rnd = database_getRandom(db);
	exception_throw(e);
	printf ( " (%d)\n", rnd );

	printf ( "CLOSE\n" );
	database_close(db);
	exception_throw(e);

	printf ( "FREE\n" );
	database_free(db);
	exception_throw(e);

	exception_free(e);

	return 0;
}
Esempio n. 6
0
int main(void) {
	EXCEPTION *e = exception_new();

	printf ( "NEW\n" );
	DATABASE *db = database_new();
	database_setException(db, e);
	exception_throw(e);

	printf ( "PARAM\n" );
	database_setName(db, "sqlite.db");

	printf ( "OPEN\n" );
	database_open(db);
	exception_throw(e);

	printf ( "VERSION" );
	char *ver = database_getVersion(db);
	exception_throw(e);
	printf ( " (%s)\n", ver );
	free(ver);

	printf ( "RANDOM" );
	int rnd = database_getRandom(db);
	exception_throw(e);
	printf ( " (%d)\n", rnd );

	printf ( "CLOSE\n" );
	database_close(db);
	exception_throw(e);

	printf ( "FREE\n" );
	database_free(db);
	exception_throw(e);

	exception_free(e);

	return 0;
}
Esempio n. 7
0
static bool cal_updatebacking(calentry_t * entry, const char * value)
{
	exception_t * e = NULL;

	switch (entry->signature)
	{
		case T_INTEGER:
		{
			int v = parse_int(value, &e);
			if (!exception_check(&e))	*(int *)entry->backing = v;
			break;
		}

		case T_DOUBLE:
		{
			double v = parse_double(value, &e);
			if (!exception_check(&e))	*(double *)entry->backing = v;
			break;
		}

		default:
		{
			LOGK(LOG_ERR, "Unknown calibration entry type %s with sig %c", entry->name, entry->signature);
			return false;
		}
	}

	if (exception_check(&e))
	{
		LOGK(LOG_ERR, "Could not set calibration entry %s: %s", entry->name, exception_message(e));
		exception_free(e);
		return false;
	}

	return true;
}
Esempio n. 8
0
		Exception::~Exception() {
			exception_free(this->obj);
		}