Is there a possibility to write templated code / custom trait pattern with usage like a delegate?

I have a try-catch block with different types and don't want to repeat myself in every method again. It's always the same, just what's tried changes, eg.:

pseudo code:

template myStuff(mixin code)
{
    try {
        code();
    }
    catch (X e) {
        ...
    }
    catch (Y e) {
        ...
    }
    ...
}

static myStuff!({
   writeln("...");
});

Reply via email to