#include <iostream>
#include <memory>
#include <stdexcept>

struct Trace {
    int value;
    explicit Trace(int input) : value{input} {
        std::cout << "create " << value << '\n';
    }
    ~Trace() {
        std::cout << "destroy " << value << '\n';
    }
};

void run() {
    auto owner = std::make_unique<Trace>(9);
    std::cout << "before throw\n";
    throw std::runtime_error{"invalid"};
}

int main() {
    try {
        run();
    } catch (const std::runtime_error& error) {
        std::cout << "caught " << error.what() << '\n';
    }
}
