Config.fromEnv constructor

Config.fromEnv()

Creates a configuration from the ZENOH_CONFIG environment variable.

The resulting config has the same lifecycle as a default Config: it may be passed to Session.open (which consumes it) or disposed.

Throws ZenohException (enriched with upstream detail where available) if ZENOH_CONFIG is unset or points at a missing/malformed config.

⚠️ The message may echo your config text. On the unstable variant it carries canon's own words for the failure, and canon's json5 parser echoes the offending value and the surrounding source line — adjacent intact secrets included — with a caret pointing at the offending token. Do not forward this message into a log, a crash report or a bug report without deciding redaction first. No redaction is applied here; see ZenohException.enriched for why a general one is not implementable at this seam. On the default stable variant no upstream detail is carried at all, so the message is the base text alone.

Implementation

factory Config.fromEnv() {
  return Config._build(
    'Failed to create config from environment',
    (ptr, errBuf, errCap, errLen) =>
        bindings.zd_config_from_env(ptr.cast(), errBuf, errCap, errLen),
  );
}