Skip to content

Commit 676225a

Browse files
committed
fix: melhorar tratamento de erro ao ler arquivos no StaticFileManager
1 parent 544ed00 commit 676225a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/Routing/StaticFileManager.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,10 @@ private static function serveFile(
326326
// Lê e envia conteúdo do arquivo
327327
$content = file_get_contents($fileInfo['path']);
328328
if ($content === false) {
329-
return $res->status(500)->json(['error' => 'Unable to read file']);
329+
return $res
330+
->withStatus(500)
331+
->withHeader('Content-Type', 'application/json')
332+
->withBody(\PivotPHP\Core\Http\Pool\Psr7Pool::getStream(json_encode(['error' => 'Unable to read file'])));
330333
}
331334

332335
// Define o body e retorna response

0 commit comments

Comments
 (0)