Skip to content

Commit 07faff7

Browse files
[9.x] Send along value to InvalidPayloadException (#47223)
* Send along value to InvalidPayloadException * Update InvalidPayloadException.php --------- Co-authored-by: Taylor Otwell <[email protected]>
1 parent f43b251 commit 07faff7

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/Illuminate/Queue/InvalidPayloadException.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,24 @@
66

77
class InvalidPayloadException extends InvalidArgumentException
88
{
9+
/**
10+
* The value that failed to decode.
11+
*
12+
* @var mixed
13+
*/
14+
public $value;
15+
916
/**
1017
* Create a new exception instance.
1118
*
1219
* @param string|null $message
20+
* @param mixed $value
1321
* @return void
1422
*/
15-
public function __construct($message = null)
23+
public function __construct($message = null, $value = null)
1624
{
1725
parent::__construct($message ?: json_last_error());
26+
27+
$this->value = $value;
1828
}
1929
}

src/Illuminate/Queue/Queue.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,11 @@ protected function createPayload($job, $queue, $data = '')
102102
$job = CallQueuedClosure::create($job);
103103
}
104104

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

107107
if (json_last_error() !== JSON_ERROR_NONE) {
108108
throw new InvalidPayloadException(
109-
'Unable to JSON encode payload. Error code: '.json_last_error()
109+
'Unable to JSON encode payload. Error code: '.json_last_error(), $value
110110
);
111111
}
112112

0 commit comments

Comments
 (0)