Torann / laravel-geoip

Determine the geographical location of website visitors based on their IP addresses.

Home Page:http://lyften.com/projects/laravel-geoip

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Exception Handling: AddressNotFoundException logged as error

Sebbo94BY opened this issue · comments

In my Laravel application, I use this GeoIP package like this:

try {
      $geoip = GeoIP($this->request->ip());
} catch(GeoIp2Exception $ex) {
      $error_msg = $ex;
}

I thought, this will NOT log any exception anymore, because Laravel will catch it and handle the issue, but I still get these log entries:

geoip.ERROR: GeoIp2\Exception\AddressNotFoundException: The address 95.91.215.44 is not in the database.

Is there a way to avoid this logging, when the exception is handled in Laravel?

And shouldn't this only be a WARNING instead or ERROR? Is it really throwing a HTTP 500 error or could it just not found the information for this specific IP address?

Do you have log_failures set to false in your config?

Ah, this is set to true. I'll change it.

But what about my other questions?

And shouldn't this only be a WARNING instead or ERROR? Is it really throwing a HTTP 500 error (to the user in Laravel) or could it just not found the information for this specific IP address?

Sorry I thought I answered that, I think I might have somewhere else then. Basically this captures all errors not just those for addresses not found in the database. To be honest I don't like capturing this and always have it turned off. It was PR that people seemed to want so I approved it. If you keep your database up to date you should rare get this message. I noticed it a lot on a server where I hadn't set the DB updating as a weekly cron.

Thanks for clarifying!

Good, then I'll just turn it off.

I've configured this cronjob in my Laravel application to keep the GeoIP up2date:

$schedule->command('geoip:update')->weekly()->wednesdays()->at('12:30');

I read, that the database is updated every Tuesday, so Wednesday should be fine.