Skip to content

Commit

Permalink
Merge pull request #8 from nurikabe/master
Browse files Browse the repository at this point in the history
Catch exceptions thrown by guessers. Specifically for notice thrown by g...
  • Loading branch information
lunetics committed Nov 6, 2013
2 parents ae68d49 + ad89773 commit 3e5dd45
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
10 changes: 9 additions & 1 deletion TimezoneGuesser/TimezoneGuesserManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,15 @@ public function runTimezoneGuessing(Request $request)
}
$this->logEvent('Timezone %s Guessing Service Loaded', ucfirst($guesser));
$guesserService = $this->getGuesser($guesser);
if (false !== $guesserService->guessTimezone($request)) {

$guessed = false;
try {
$guessed = $guesserService->guessTimezone($request);
} catch (\Exception $e) {
// Some guessers like the GeoTimezoneGuesser may throw an exception. Log the problem without crashing.
$this->logEvent($e->getMessage());
}
if (false !== $guessed) {
$timezone = $guesserService->getIdentifiedTimezone();
$this->logEvent('Timezone has been identified : ( %s )', $timezone);

Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
"minimum-stability": "dev",
"require": {
"php": ">=5.3.3",
"symfony/framework-bundle": ">=2.1,<2.4-dev",
"symfony/yaml": ">=2.1,<2.4-dev",
"symfony/validator": ">=2.1,<2.4-dev"
"symfony/framework-bundle": "~2.1",
"symfony/yaml": "~2.1",
"symfony/validator": "~2.1"
},
"require-dev": {
"ext-intl": "*"
Expand Down

0 comments on commit 3e5dd45

Please sign in to comment.