mirror of
https://github.com/shlinkio/shlink.git
synced 2024-12-23 07:33:58 -06:00
Split try catch to prevent undefined variables
This commit is contained in:
parent
e5e1aa2ff4
commit
a2294704e6
@ -1,7 +1,6 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use Fig\Http\Message\RequestMethodInterface as RequestMethod;
|
||||
use Shlinkio\Shlink\Rest\Action;
|
||||
|
||||
return [
|
||||
|
@ -57,7 +57,15 @@ abstract class AbstractCreateShortCodeAction extends AbstractRestAction
|
||||
$shortCodeMeta = $shortCodeData->getMeta();
|
||||
$longUrl = $shortCodeData->getLongUrl();
|
||||
$customSlug = $shortCodeMeta->getCustomSlug();
|
||||
} catch (ValidationException | InvalidArgumentException $e) {
|
||||
$this->logger->warning('Provided data is invalid.' . PHP_EOL . $e);
|
||||
return new JsonResponse([
|
||||
'error' => RestUtils::INVALID_ARGUMENT_ERROR,
|
||||
'message' => $this->translator->translate('Provided data is invalid'),
|
||||
], self::STATUS_BAD_REQUEST);
|
||||
}
|
||||
|
||||
try {
|
||||
$shortCode = $this->urlShortener->urlToShortCode(
|
||||
$longUrl,
|
||||
$shortCodeData->getTags(),
|
||||
@ -94,12 +102,6 @@ abstract class AbstractCreateShortCodeAction extends AbstractRestAction
|
||||
$customSlug
|
||||
),
|
||||
], self::STATUS_BAD_REQUEST);
|
||||
} catch (ValidationException | InvalidArgumentException $e) {
|
||||
$this->logger->warning('Provided data is invalid.' . PHP_EOL . $e);
|
||||
return new JsonResponse([
|
||||
'error' => RestUtils::INVALID_ARGUMENT_ERROR,
|
||||
'message' => $this->translator->translate('Provided data is invalid'),
|
||||
], self::STATUS_BAD_REQUEST);
|
||||
} catch (\Throwable $e) {
|
||||
$this->logger->error('Unexpected error creating shortcode.' . PHP_EOL . $e);
|
||||
return new JsonResponse([
|
||||
|
Loading…
Reference in New Issue
Block a user