feat: add error handling

This commit is contained in:
Maël Gangloff
2024-07-14 11:20:04 +02:00
parent 24d21fbc88
commit d202aa8964
2 changed files with 30 additions and 7 deletions

View File

@@ -4,6 +4,7 @@
namespace App\Controller;
use App\Service\RDAPService;
use Exception;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
@@ -22,7 +23,11 @@ class TestController extends AbstractController
#[Route(path: '/test/register/{fqdn}', name: 'test_register_domain')]
public function testRegisterDomain(string $fqdn): Response
{
$this->RDAPService->registerDomain($fqdn);
try {
$this->RDAPService->registerDomain($fqdn);
} catch (Exception $e) {
return new Response($e->getMessage(), Response::HTTP_INTERNAL_SERVER_ERROR);
}
return new Response();
}