-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added default exception handler fallback for PutCuratorReviewImport.
CI now responds with: HTTP server responded with error: 500 "Internal Server Error". {"success":25,"clanid":32686107}
- Loading branch information
Showing
2 changed files
with
38 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace ScriptFUSION\Steam250\Curator\Import; | ||
|
||
use ScriptFUSION\Porter\Connector\Recoverable\ExponentialAsyncDelayRecoverableExceptionHandler; | ||
use ScriptFUSION\Porter\Connector\Recoverable\RecoverableException; | ||
use ScriptFUSION\Porter\Connector\Recoverable\RecoverableExceptionHandler; | ||
use ScriptFUSION\Porter\Net\Http\HttpServerException; | ||
use ScriptFUSION\Retry\ExceptionHandler\AsyncExponentialBackoffExceptionHandler; | ||
|
||
final class PutCuratorReviewExceptionHandler implements RecoverableExceptionHandler | ||
{ | ||
private RecoverableExceptionHandler $exceptionHandler; | ||
|
||
public function initialize(): void | ||
{ | ||
$this->exceptionHandler = new ExponentialAsyncDelayRecoverableExceptionHandler( | ||
// Wait at least a minute before trying again. | ||
600 * AsyncExponentialBackoffExceptionHandler::DEFAULT_COEFFICIENT | ||
); | ||
$this->exceptionHandler->initialize(); | ||
} | ||
|
||
public function __invoke(RecoverableException $exception): void | ||
{ | ||
if ($exception instanceof HttpServerException && $exception->getCode() === 400) { | ||
$response = \json_decode($exception->getResponse()->getBody()); | ||
if ($response->success === 8) { | ||
throw new \RuntimeException('Invalid param: app probably deleted.'); | ||
} | ||
} | ||
|
||
($this->exceptionHandler)($exception); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters