Given more semantic cases in which a visit cannot be located

This commit is contained in:
Alejandro Celaya
2019-02-26 21:39:45 +01:00
parent c70077c525
commit 2d1d7357a3
4 changed files with 49 additions and 6 deletions

View File

@@ -83,14 +83,14 @@ class ProcessVisitsCommand extends Command
'<comment>Ignored visit with no IP address</comment>',
OutputInterface::VERBOSITY_VERBOSE
);
throw new IpCannotBeLocatedException('Ignored visit with no IP address');
throw IpCannotBeLocatedException::forEmptyAddress();
}
$ipAddr = $visit->getRemoteAddr();
$this->output->write(sprintf('Processing IP <fg=blue>%s</>', $ipAddr));
if ($ipAddr === IpAddress::LOCALHOST) {
$this->output->writeln(' [<comment>Ignored localhost address</comment>]');
throw new IpCannotBeLocatedException('Ignored localhost address');
throw IpCannotBeLocatedException::forLocalhost();
}
try {
@@ -101,7 +101,7 @@ class ProcessVisitsCommand extends Command
$this->getApplication()->renderException($e, $this->output);
}
throw new IpCannotBeLocatedException('An error occurred while locating IP', $e->getCode(), $e);
throw IpCannotBeLocatedException::forError($e);
}
}
}