mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-09 02:58:23 +01:00
Add try catch
This commit is contained in:
@@ -58,13 +58,12 @@ class DolGeoIP
|
|||||||
*/
|
*/
|
||||||
public function __construct($type, $datfile)
|
public function __construct($type, $datfile)
|
||||||
{
|
{
|
||||||
global $conf;
|
|
||||||
|
|
||||||
$geoipversion = '2'; // 'php', or geoip version '2'
|
$geoipversion = '2'; // 'php', or geoip version '2'
|
||||||
if (getDolGlobalString('GEOIP_VERSION')) {
|
if (getDolGlobalString('GEOIP_VERSION')) {
|
||||||
$geoipversion = getDolGlobalString('GEOIP_VERSION');
|
$geoipversion = getDolGlobalString('GEOIP_VERSION');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
if ($type == 'country') {
|
if ($type == 'country') {
|
||||||
// geoip may have been already included with PEAR
|
// geoip may have been already included with PEAR
|
||||||
if ($geoipversion == '2' || ($geoipversion != 'php' && !function_exists('geoip_country_code_by_name'))) {
|
if ($geoipversion == '2' || ($geoipversion != 'php' && !function_exists('geoip_country_code_by_name'))) {
|
||||||
@@ -85,6 +84,12 @@ class DolGeoIP
|
|||||||
print 'ErrorBadParameterInConstructor';
|
print 'ErrorBadParameterInConstructor';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$this->error = $e->getMessage();
|
||||||
|
$this->errorlabel = 'Exception '.$this->error;
|
||||||
|
dol_syslog('DolGeoIP '.$this->errorlabel, LOG_ERR);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Here, function exists (embedded into PHP or exists because we made include)
|
// Here, function exists (embedded into PHP or exists because we made include)
|
||||||
if (empty($type) || empty($datfile)) {
|
if (empty($type) || empty($datfile)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user