Skip to content

Commit

Permalink
Handle HttpExceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Nov 13, 2023
1 parent 4972dae commit 2d6647e
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions packages/realtime-compiler/src/Http/LiveEditController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

namespace Hyde\RealtimeCompiler\Http;

use Desilva\Microserve\Response;
use Desilva\Microserve\JsonResponse;
use Symfony\Component\HttpKernel\Exception\HttpException;

/**
* @internal This class is not intended to be edited outside the Hyde Realtime Compiler.
Expand All @@ -14,9 +15,24 @@ class LiveEditController extends BaseController
protected bool $withConsoleOutput = true;
protected bool $withSession = true;

public function handle(): Response
public function handle(): JsonResponse
{
$this->authorizePostRequest();
try {
$this->authorizePostRequest();

return $this->handleRequest();
} catch (HttpException $exception) {
if ($this->expectsJson()) {
return $this->sendJsonErrorResponse($exception->getStatusCode(), $exception->getMessage());
}

throw $exception;
}
}

protected function handleRequest(): JsonResponse
{
//
}

public static function enabled(): bool
Expand Down

0 comments on commit 2d6647e

Please sign in to comment.