Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions packages/router/src/Exceptions/DevelopmentException.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use Tempest\Http\IsResponse;
use Tempest\Http\Request;
use Tempest\Http\Response;
use Tempest\Http\Status;
use Tempest\Support\Filesystem;
use Tempest\View\Exceptions\ViewCompilationFailed;
use Tempest\View\GenericView;
Expand All @@ -27,7 +26,7 @@ final class DevelopmentException implements Response

public function __construct(Throwable $throwable, Response $response, Request $request)
{
$this->status = Status::INTERNAL_SERVER_ERROR;
$this->status = $response->status;

if (! Filesystem\exists(__DIR__ . '/local/dist/main.js')) {
$this->body = 'The development exception interface is not built.';
Expand Down
15 changes: 15 additions & 0 deletions tests/Integration/Http/Exceptions/HtmlExceptionRendererTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,21 @@ public function renders_development_exception_in_local_environment(): void
);
}

#[Test]
public function development_exception_preserves_http_request_failed_status(): void
{
$this->container->singleton(Environment::class, Environment::LOCAL);
$this->container->singleton(GenericRequest::class, new GenericRequest(
method: Method::GET,
uri: '/',
));

$response = $this->renderer->render(new HttpRequestFailed(Status::NOT_ACCEPTABLE));

$this->assertInstanceOf(DevelopmentException::class, $response);
$this->assertSame(Status::NOT_ACCEPTABLE, $response->status);
}

#[Test]
public function does_not_render_development_exception_for_not_found_in_local(): void
{
Expand Down
Loading