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

[9.x] Send along value to InvalidPayloadException #47223

Merged
merged 2 commits into from
May 30, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/Illuminate/Queue/InvalidPayloadException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,24 @@

class InvalidPayloadException extends InvalidArgumentException
{
/**
* The value that failed to decode.
*
* @var mixed
*/
public $value;

/**
* Create a new exception instance.
*
* @param string|null $message
* @param mixed $value
* @return void
*/
public function __construct($message = null)
public function __construct($message = null, $value = null)
{
parent::__construct($message ?: json_last_error());

$this->value = $value;
}
}
4 changes: 2 additions & 2 deletions src/Illuminate/Queue/Queue.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ protected function createPayload($job, $queue, $data = '')
$job = CallQueuedClosure::create($job);
}

$payload = json_encode($this->createPayloadArray($job, $queue, $data), \JSON_UNESCAPED_UNICODE);
$payload = json_encode($value = $this->createPayloadArray($job, $queue, $data), \JSON_UNESCAPED_UNICODE);

if (json_last_error() !== JSON_ERROR_NONE) {
throw new InvalidPayloadException(
'Unable to JSON encode payload. Error code: '.json_last_error()
'Unable to JSON encode payload. Error code: '.json_last_error(), $value
);
}

Expand Down