if-error

xod/core/if-error

Outputs value from IN if it does not carry an error. Otherwise, defaults to value from DEF
if-error
@/if-error
Outputs value from IN if it does not carry an error. Otherwise, defaults to value from DEF
INgeneric t1
DEFgeneric t1
if-error
OUT
IN
DEF
OUTgeneric t1

C++ implementation

#pragma XOD error_raise enable
#pragma XOD error_catch enable

node {
    void evaluate(Context ctx) {
        auto defError = getError<input_DEF>(ctx);

        if (defError) {
            // "DEF" input should not contain an error — reraise it
            raiseError<output_OUT>(ctx);
        } else {
            emitValue<output_OUT>(ctx, getError<input_IN>(ctx) ? getValue<input_DEF>(ctx) : getValue<input_IN>(ctx));
        }
    }
}