You could try doing following thing:

```C++
template <bool sync>
void your_fn() {
  const char* err = NULL;
  switch(...) {
    case ...
      err = "something";
      break;
  }

  if (sync)
    Throw(err)
  else
    ZCtx::Error(ctx, err)
}
```

Note that it is mostlye a pseudo-code ;)