#include <iostream>
#include <exception>
#include <stdexcept>

class Application {
public:
	Application() {}
	
	bool connect() {
		std::cout << "connecting" << std::endl;
		return true;
	}
	
	void disconnect() {
		std::cout << "disconnecting" << std::endl;
	}

	~Application() {
		disconnect();
		
		if (std::uncaught_exception()) {
			createCrashReport();
		}
	}
protected:
	void createCrashReport() {
		std::cerr << "Application was halted by an exception" << std::endl;
	}
};

void riskyThing() {
	throw std::runtime_error("Fuck you!");
}

void foo() {
	Application app;
	app.connect();

	riskyThing();
}

int main() {
	foo();
	
	return 0;
}