mirror of
https://github.com/shlinkio/shlink.git
synced 2025-03-14 04:00:57 +03:00
Updated status returned in REST endpoints to be 404 when something is not found
This commit is contained in:
parent
93713689d7
commit
3bd4f506e0
2 changed files with 8 additions and 5 deletions
|
@ -25,7 +25,7 @@ class GetVisitsAction extends AbstractRestAction
|
|||
|
||||
/**
|
||||
* GetVisitsAction constructor.
|
||||
* @param VisitsTrackerInterface|VisitsTracker $visitsTracker
|
||||
* @param VisitsTrackerInterface $visitsTracker
|
||||
* @param TranslatorInterface $translator
|
||||
*
|
||||
* @Inject({VisitsTracker::class, "translator"})
|
||||
|
@ -59,8 +59,11 @@ class GetVisitsAction extends AbstractRestAction
|
|||
} catch (InvalidArgumentException $e) {
|
||||
return new JsonResponse([
|
||||
'error' => RestUtils::getRestErrorCodeFromException($e),
|
||||
'message' => sprintf($this->translator->translate('Provided short code "%s" is invalid'), $shortCode),
|
||||
], 400);
|
||||
'message' => sprintf(
|
||||
$this->translator->translate('Provided short code "%s" does not exist'),
|
||||
$shortCode
|
||||
),
|
||||
], 404);
|
||||
} catch (\Exception $e) {
|
||||
return new JsonResponse([
|
||||
'error' => RestUtils::UNKNOWN_ERROR,
|
||||
|
|
|
@ -50,8 +50,8 @@ class ResolveUrlAction extends AbstractRestAction
|
|||
if (! isset($longUrl)) {
|
||||
return new JsonResponse([
|
||||
'error' => RestUtils::INVALID_ARGUMENT_ERROR,
|
||||
'message' => sprintf($this->translator->translate('No URL found for shortcode "%s"'), $shortCode),
|
||||
], 400);
|
||||
'message' => sprintf($this->translator->translate('No URL found for short code "%s"'), $shortCode),
|
||||
], 404);
|
||||
}
|
||||
|
||||
return new JsonResponse([
|
||||
|
|
Loading…
Add table
Reference in a new issue