Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.x] Improve the exception thrown when JSON encoding response contents fails #36851

Merged
merged 2 commits into from
Apr 2, 2021
Merged
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
4 changes: 4 additions & 0 deletions src/Illuminate/Http/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ public function setContent($content)
$this->header('Content-Type', 'application/json');

$content = $this->morphToJson($content);

if ($content === false) {
throw new \UnexpectedValueException(sprintf('Failed to convert the provided Response content to JSON with the message: %s', json_last_error_msg()));
}
}

// If this content implements the "Renderable" interface then we will call the
Expand Down