master

laravel/framework

Last updated at: 29/12/2023 09:24

InvalidPayloadException.php

TLDR

This file defines the InvalidPayloadException class in the Illuminate\Queue namespace. This class extends the InvalidArgumentException class and is used for representing exceptions when decoding payloads.

Classes

InvalidPayloadException

This class represents an exception that is thrown when a payload fails to decode. It extends the InvalidArgumentException class. It has the following properties:

  • $value: The value that failed to decode.

It has the following methods:

  • __construct($message = null, $value = null): This method is the constructor of the class. It takes in an optional $message parameter, which represents the exception message, and an optional $value parameter, which represents the value that failed to decode. It calls the parent constructor with the $message parameter, using json_last_error() as the default value if $message is not provided, and assigns the $value parameter to the $value property.

END

<?php

namespace Illuminate\Queue;

use InvalidArgumentException;

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, $value = null)
    {
        parent::__construct($message ?: json_last_error());

        $this->value = $value;
    }
}