/** * @param string $address * @param int $limit * * @return $this */ public function geocode($address, $limit = 1) { try { $this->addresses = $this->geocoder->limit($limit)->geocode($address); } catch (\Geocoder\Exception\NoResult $ex) { $this->errorKey = 'no_results'; $this->error = RootLocator_Errors::noResults(); PerchUtil::debug(sprintf('Locator: %s', $ex->getMessage()), 'error'); } catch (\Geocoder\Exception\HttpError $ex) { $this->errorKey = 'http_error'; $this->error = RootLocator_Errors::httpError(); PerchUtil::debug(sprintf('Locator: %s', $ex->getMessage()), 'error'); } catch (\Geocoder\Exception\InvalidCredentials $ex) { $this->errorKey = 'invalid_credentials'; $this->error = RootLocator_Errors::invalidCredentials(); PerchUtil::debug(sprintf('Locator: %s', $ex->getMessage()), 'error'); } catch (\Geocoder\Exception\QuotaExceeded $ex) { $this->errorKey = 'quota_exceeded'; $this->error = RootLocator_Errors::quotaExceeded(); PerchUtil::debug(sprintf('Locator: %s', $ex->getMessage()), 'error'); } catch (Exception $ex) { $this->errorKey = 'unknown'; $this->error = RootLocator_Errors::unknown(); PerchUtil::debug(sprintf('Locator: %s', $ex->getMessage()), 'error'); } return $this; }