Skip to content
This repository was archived by the owner on Jun 1, 2022. It is now read-only.

Remove die calls, add source description to error messages. #28

Merged
merged 1 commit into from
Nov 11, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/geoip.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1532,7 +1532,7 @@ function geoip_open($filename, $flags)
if ($gi->flags & GEOIP_SHARED_MEMORY) {
$gi->shmid = @shmop_open(GEOIP_SHM_KEY, "a", 0, 0);
} else {
$gi->filehandle = fopen($filename, "rb") or die("Can not open $filename\n");
$gi->filehandle = fopen($filename, "rb") or trigger_error("GeoIP API: Can not open $filename\n", E_USER_ERROR);
if ($gi->flags & GEOIP_MEMORY_CACHE) {
$s_array = fstat($gi->filehandle);
$gi->memory_buffer = fread($gi->filehandle, $s_array['size']);
Expand Down Expand Up @@ -1693,7 +1693,7 @@ function _geoip_seek_country_v6($gi, $ipnum)
);
} else {
fseek($gi->filehandle, 2 * $gi->record_length * $offset, SEEK_SET) == 0
or die("fseek failed");
or trigger_error("GeoIP API: fseek failed", E_USER_ERROR);
$buf = fread($gi->filehandle, 2 * $gi->record_length);
}
$x = array(0, 0);
Expand All @@ -1718,7 +1718,7 @@ function _geoip_seek_country_v6($gi, $ipnum)
$offset = $x[0];
}
}
trigger_error("error traversing database - perhaps it is corrupt?", E_USER_ERROR);
trigger_error("GeoIP API: Error traversing database - perhaps it is corrupt?", E_USER_ERROR);
return false;
}

Expand All @@ -1740,7 +1740,7 @@ function _geoip_seek_country($gi, $ipnum)
);
} else {
fseek($gi->filehandle, 2 * $gi->record_length * $offset, SEEK_SET) == 0
or die("fseek failed");
or trigger_error("GeoIP API: fseek failed", E_USER_ERROR);
$buf = fread($gi->filehandle, 2 * $gi->record_length);
}
$x = array(0, 0);
Expand All @@ -1761,7 +1761,7 @@ function _geoip_seek_country($gi, $ipnum)
$offset = $x[0];
}
}
trigger_error("error traversing database - perhaps it is corrupt?", E_USER_ERROR);
trigger_error("GeoIP API: Error traversing database - perhaps it is corrupt?", E_USER_ERROR);
return false;
}

Expand Down