/** * Attempt to take the appropriate action based on the * EVE API Exception. Returns a boolean indicating * if the calling job should continue or not. * * @param \Seat\Eveapi\Models\JobTracking $job_tracker * @param \Seat\Eveapi\Models\Eve\ApiKey $api_key * @param \Exception $exception * * @return bool * @throws \Exception */ public function handleApiException(JobTracking $job_tracker, ApiKey $api_key, $exception) { // Start by allowing the parent job to continue. $should_continue = true; // No matter what the error, we will increment the // Api Error Counter. $this->incrementApiErrorCount(); // Errors from the EVE API should be treated seriously. If // these are ignored, one may risk having the calling IP // banned entirely. We don't want that, so lets check // and act accordingly based on the error code. We also rely // entirely on PhealNG to pass us the proper error codes. switch ($exception->getCode()) { // Invalid contractID something. Probably the // most annoying freaking response code that // CCP has! case 135: break; // "API key authentication failure." // "API key authentication failure." case 202: // "Authentication failure." // "Authentication failure." case 203: case 204: // "Authentication failure." // "Authentication failure." case 205: // "Authentication failure." // "Authentication failure." case 210: // "Authentication failure (final pass)." // "Authentication failure (final pass)." case 212: $api_key->update(['enabled' => false, 'last_error' => $exception->getCode() . ':' . $exception->getMessage()]); $should_continue = false; break; // "Invalid Corporation Key. Key owner does not fullfill role // requirements anymore." // "Invalid Corporation Key. Key owner does not fullfill role // requirements anymore." case 220: $api_key->update(['enabled' => false, 'last_error' => $exception->getCode() . ':' . $exception->getMessage()]); $should_continue = false; break; // "Illegal page request! Please verify the access granted by the key you are using!." // "Illegal page request! Please verify the access granted by the key you are using!." case 221: // Not 100% sure how to handle this one. This call has no // access mask requirement... $api_key->update(['last_error' => $exception->getCode() . ':' . $exception->getMessage()]); break; // "Key has expired. Contact key owner for access renewal." // "Key has expired. Contact key owner for access renewal." case 222: $api_key->update(['enabled' => false, 'last_error' => $exception->getCode() . ':' . $exception->getMessage()]); $should_continue = false; break; // "Authentication failure. Legacy API keys can no longer be // used. Please create a new key on support.eveonline.com // and make sure your application supports Customizable // API Keys." // "Authentication failure. Legacy API keys can no longer be // used. Please create a new key on support.eveonline.com // and make sure your application supports Customizable // API Keys." case 223: // The API we are working with is waaaaaay too old. $api_key->update(['enabled' => false, 'last_error' => $exception->getCode() . ':' . $exception->getMessage()]); $should_continue = false; break; // "Web site database temporarily disabled." // "Web site database temporarily disabled." case 901: $this->markEveApiDown(); $should_continue = false; break; // "EVE backend database temporarily disabled."" // "EVE backend database temporarily disabled."" case 902: $this->markEveApiDown(); $should_continue = false; break; // "Your IP address has been temporarily blocked because it // is causing too many errors. See the cacheUntil // timestamp for when it will be opened again. // IPs that continually cause a lot of errors // in the API will be permanently banned, // please take measures to minimize // problematic API calls from your // application." // "Your IP address has been temporarily blocked because it // is causing too many errors. See the cacheUntil // timestamp for when it will be opened again. // IPs that continually cause a lot of errors // in the API will be permanently banned, // please take measures to minimize // problematic API calls from your // application." case 904: // Get time of IP ban in minutes, rounded up to the next whole minute $time = round(($exception->cached_until_unixtime - $exception->request_time_unixtime) / 60, 0, PHP_ROUND_HALF_UP); $this->markEveApiDown($time); $should_continue = false; break; // We got a problem we don't know what to do with, so log // and throw the exception so that the can debug it. // We got a problem we don't know what to do with, so log // and throw the exception so that the can debug it. default: throw $exception; break; } // Update the Job itself with the error information $this->reportJobError($job_tracker, $exception); return $should_continue; }