#include <iostream>
#include <vector>
#include <string>
//#include <unistd.h>

int open() {
	return 42;
}

void close(int handle) {}

struct Context {
	int handle;
	std::vector<std::string> errors;
};

class File {
	Context &ctx_;
public:
	File(Context &ctx) : ctx_(ctx)
	{
		try {
			ctx.handle = open();
		} catch(...) {
			ctx_.errors.push_back("Unable to open file");
		}		
	}
	~File() {
		try {
			close(ctx_.handle);
		} catch(...) {
			ctx_.errors.push_back("An error occured");
		}
	}
};

int main() {
	Context ctx;
	{
		File f(ctx);
	}
	for (auto e : ctx.errors)
		std::cout << e << std::endl;
	return 0;
}