MCRouterOptionException::getErrors

public function getErrors(): array<array<string>>;

Returns

  • array<array<string>>

Examples

The following example shows you how to get the errors that are available when bad options are passed to the MCRouter constructor using MCRouterOptionException::getErrors

function construct_mcrouter(): void {
  $servers = Vector {\getenv('HHVM_TEST_MCROUTER')};
  // For many use cases, calling MCRouter::createSimple($servers) would
  // suffice here. But this shows you how to explicitly create the configuration
  // options for creating an instance of MCRouter

  // This has a bad option setup
  $options = array('asynclog_disable' => 'purple');

  $mc = null;

  try {
    $mc = new \MCRouter($options);
  } catch (\MCRouterOptionException $ex) {
    \var_dump($ex->getErrors());
  }
}

function run(): void {
  construct_mcrouter();
}

run();
Output
array(1) {
  [0]=>
  array(3) {
    ["option"]=>
    string(16) "asynclog_disable"
    ["value"]=>
    string(6) "purple"
    ["error"]=>
    string(99) "couldn't convert value to integer. Exception: folly/Conv.cpp(262): Invalid value for bool: 'purple'"
  }
}