Improved error response in edit tag request

This commit is contained in:
Alejandro Celaya 2016-08-21 17:55:26 +02:00
parent 1da285a63a
commit d7b18776f1

View file

@ -64,7 +64,10 @@ class EditTagsAction extends AbstractRestAction
$shortUrl = $this->shortUrlService->setTagsByShortCode($shortCode, $tags);
return new JsonResponse(['tags' => $shortUrl->getTags()->toArray()]);
} catch (InvalidShortCodeException $e) {
return $out($request, $response->withStatus(404), 'Not found');
return new JsonResponse([
'error' => RestUtils::getRestErrorCodeFromException($e),
'message' => sprintf($this->translator->translate('No URL found for short code "%s"'), $shortCode),
], 404);
}
}
}