From 1abb9e98c9973a1df194b5f23f077e92184645d7 Mon Sep 17 00:00:00 2001 From: Mark Friedrich Date: Sun, 10 Jun 2018 14:39:11 +0200 Subject: [PATCH 1/4] - no error logging in case `getRouteData()` "No route found" HTTP 404 --- app/ESI.php | 5 ++++- app/Lib/WebClient.php | 16 +++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/app/ESI.php b/app/ESI.php index 24f4561..c62506e 100644 --- a/app/ESI.php +++ b/app/ESI.php @@ -659,6 +659,9 @@ public function getUniverseTypesData(int $typeId, array $additionalOptions = []) * @return array */ public function getRouteData(int $sourceId, int $targetId, array $options = []) : array { + // 404 'No route found' error + $additionalOptions['suppressHTTPLogging'] = [404]; + $urlParams = []; if( !empty($options['avoid']) ){ $urlParams['avoid'] = $options['avoid']; @@ -677,7 +680,7 @@ public function getRouteData(int $sourceId, int $targetId, array $options = []) $url = $this->getEndpointURL(['routes', 'GET'], [$sourceId, $targetId], $urlParams); $routeData = []; - $response = $this->request($url, 'GET'); + $response = $this->request($url, 'GET', '', $additionalOptions); if($response->error){ $routeData['error'] = $response->error; diff --git a/app/Lib/WebClient.php b/app/Lib/WebClient.php index 46de4f2..d506969 100644 --- a/app/Lib/WebClient.php +++ b/app/Lib/WebClient.php @@ -383,13 +383,15 @@ public function request( $url, array $options = null, $additionalOptions = [], $ case 'ok': // HTTP 2xx break; case 'err_client': // HTTP 4xx - $errorMsg = $this->getErrorMessageFromJsonResponse( - $statusCode, - $options['method'], - $url, - $responseBody - ); - $this->getLogger($statusType)->write($errorMsg); + if( !in_array($statusCode, (array)$additionalOptions['suppressHTTPLogging']) ){ + $errorMsg = $this->getErrorMessageFromJsonResponse( + $statusCode, + $options['method'], + $url, + $responseBody + ); + $this->getLogger($statusType)->write($errorMsg); + } break; case 'err_server': // HTTP 5xx $retry = true; From fb9da7c8db6d648ee1507b01bd9a0bda8fcff07c Mon Sep 17 00:00:00 2001 From: Mark Friedrich Date: Sun, 10 Jun 2018 15:18:35 +0200 Subject: [PATCH 2/4] - no error logging in case `getCorporationRoles()` "Character cannot grant roles" HTTP 403 --- app/ESI.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/ESI.php b/app/ESI.php index c62506e..078d1af 100644 --- a/app/ESI.php +++ b/app/ESI.php @@ -294,13 +294,18 @@ public function getAllianceData(int $allianceId) : array { * @return array */ public function getCorporationRoles(int $corporationId, string $accessToken) : array { + // 403 'Character cannot grant roles' error + $additionalOptions['suppressHTTPLogging'] = [403]; + $url = $this->getEndpointURL(['corporations', 'roles', 'GET'], [$corporationId]); $rolesData = []; - $response = $this->request($url, 'GET', $accessToken); + $response = $this->request($url, 'GET', $accessToken, $additionalOptions); - if( !empty($response) ){ + if($response->error){ + $rolesData['error'] = $response->error; + }elseif( !empty($response) ){ foreach((array)$response as $characterRuleData){ - $rolesData[(int)$characterRuleData->character_id] = array_map('strtolower', (array)$characterRuleData->roles); + $rolesData['roles'][(int)$characterRuleData->character_id] = array_map('strtolower', (array)$characterRuleData->roles); } } From d409a6bbbfea5bc418b0d4c41378011991ad90ba Mon Sep 17 00:00:00 2001 From: Mark Friedrich Date: Fri, 22 Jun 2018 14:56:08 +0200 Subject: [PATCH 3/4] - improved error handling for `getUniverseSystemData()` --- app/ESI.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/ESI.php b/app/ESI.php index 078d1af..23864ce 100644 --- a/app/ESI.php +++ b/app/ESI.php @@ -398,7 +398,7 @@ public function getUniverseSystemData(int $systemId) : array { $systemData = []; $response = $this->request($url, 'GET'); - if( !empty($response) ){ + if( !$response->error && !empty($response) ){ $systemData = (new namespace\Mapper\System($response))->getData(); } From f7bfa31df8bdc3765784bb183d8b4d804a229291 Mon Sep 17 00:00:00 2001 From: Mark Friedrich Date: Fri, 22 Jun 2018 15:16:04 +0200 Subject: [PATCH 4/4] - improved error handling for `getUniverseRegions()` - improved error handling for `getUniverseRegionData()` - improved error handling for `getUniverseConstellations()` - improved error handling for `getUniverseConstellationData()` - improved error handling for `getUniverseSystems()` - improved error handling for `getUniverseStarData()` - improved error handling for `getUniversePlanetData()` - improved error handling for `getUniverseStargateData()` --- app/ESI.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/ESI.php b/app/ESI.php index 23864ce..9709293 100644 --- a/app/ESI.php +++ b/app/ESI.php @@ -320,7 +320,7 @@ public function getUniverseRegions() : array { $regionData = []; $response = $this->request($url, 'GET'); - if( !empty($response) ){ + if( !$response->error && !empty($response) ){ $regionData = array_unique( array_map('intval', $response) ); } @@ -336,7 +336,7 @@ public function getUniverseRegionData(int $regionId) : array { $regionData = []; $response = $this->request($url, 'GET'); - if( !empty($response) ){ + if( !$response->error && !empty($response) ){ $regionData = (new namespace\Mapper\Region($response))->getData(); } @@ -351,7 +351,7 @@ public function getUniverseConstellations() : array{ $constellationData = []; $response = $this->request($url, 'GET'); - if( !empty($response) ){ + if( !$response->error && !empty($response) ){ $constellationData = array_unique( array_map('intval', $response) ); } @@ -367,7 +367,7 @@ public function getUniverseConstellationData(int $constellationId) : array { $constellationData = []; $response = $this->request($url, 'GET'); - if( !empty($response) ){ + if( !$response->error && !empty($response) ){ $constellationData = (new namespace\Mapper\Constellation($response))->getData(); } @@ -382,7 +382,7 @@ public function getUniverseSystems() : array{ $systemData = []; $response = $this->request($url, 'GET'); - if( !empty($response) ){ + if( !$response->error && !empty($response) ){ $systemData = array_unique( array_map('intval', $response) ); } @@ -414,7 +414,7 @@ public function getUniverseStarData(int $starId) : array { $starData = []; $response = $this->request($url, 'GET'); - if( !empty($response) ){ + if( !$response->error && !empty($response) ){ $starData = (new namespace\Mapper\Universe\Star($response))->getData(); if( !empty($starData) ){ $starData['id'] = $starId; @@ -433,7 +433,7 @@ public function getUniversePlanetData(int $planetId) : array { $planetData = []; $response = $this->request($url, 'GET'); - if( !empty($response) ){ + if( !$response->error && !empty($response) ){ $planetData = (new namespace\Mapper\Universe\Planet($response))->getData(); } @@ -449,7 +449,7 @@ public function getUniverseStargateData(int $stargateId) : array { $stargateData = []; $response = $this->request($url, 'GET'); - if( !empty($response) ){ + if( !$response->error && !empty($response) ){ $stargateData = (new namespace\Mapper\Universe\Stargate($response))->getData(); }