diff --git a/src/Drivers/IPInfoDriver.php b/src/Drivers/IPInfoDriver.php index 7abcf27..f863c8b 100644 --- a/src/Drivers/IPInfoDriver.php +++ b/src/Drivers/IPInfoDriver.php @@ -2,6 +2,7 @@ namespace PulkitJalan\IPGeolocation\Drivers; +use Throwable; use Illuminate\Support\Arr; use GuzzleHttp\Client as GuzzleClient; use PulkitJalan\IPGeolocation\Exceptions\InvalidCredentialsException; @@ -63,7 +64,7 @@ public function getRaw($ip) $response = $this->guzzle->get($url); return json_decode($response->getBody(), true); - } catch (\Exception $e) { + } catch (Throwable $e) { return []; } } diff --git a/src/IPGeolocation.php b/src/IPGeolocation.php index 228fdeb..0463bc1 100644 --- a/src/IPGeolocation.php +++ b/src/IPGeolocation.php @@ -2,6 +2,7 @@ namespace PulkitJalan\IPGeolocation; +use Throwable; use Illuminate\Support\Arr; use Illuminate\Support\Str; use GuzzleHttp\Client as GuzzleClient; @@ -126,7 +127,7 @@ public function getRaw() if (! $data) { try { $data = $this->getDriver()->getRaw($ip); - } catch (\Exception $e) { + } catch (Throwable $e) { throw new IPGeolocationException('Failed to get raw ip geolocation data', 0, $e); } @@ -155,7 +156,7 @@ protected function getData() if (! $data) { try { $data = $this->getDriver()->get($ip); - } catch (\Exception $e) { + } catch (Throwable $e) { throw new IPGeolocationException('Failed to get ip geolocation data', 0, $e); } diff --git a/src/IPGeolocationUpdater.php b/src/IPGeolocationUpdater.php index bc48d27..6d3a32a 100644 --- a/src/IPGeolocationUpdater.php +++ b/src/IPGeolocationUpdater.php @@ -3,7 +3,7 @@ namespace PulkitJalan\IPGeolocation; use PharData; -use Exception; +use Throwable; use Illuminate\Support\Arr; use GuzzleHttp\Client as GuzzleClient; use PulkitJalan\IPGeolocation\Exceptions\InvalidDatabaseException; @@ -93,7 +93,7 @@ protected function updateMaxmindDatabase() array_map(fn ($file) => $this->removeIfExists($file), glob("$dir/*.*")); @rmdir($dir); - } catch (Exception $e) { + } catch (Throwable $e) { return false; }