Why Laravel throw_unless giving internal server error?

Viewed 226

I am using laravel throw_unless in my code. It works fine in local PC, but in production server it always throw "Server Error".

    throw_unless($product->unit_price > 1, OutOfStockException::class,'Product out of stock!');

and exception class:

class OutOfStockException extends Exception
{
    public function __construct($message = "")
    {
        parent::__construct($message);
    }

    public function report() {
        \Log::debug('Product out of stock');
    }
}
1 Answers

After changing my Exception class it's working.

namespace App\Exceptions;

use Exception;
use App\Core\Exceptions\RenderAble;

class OutOfStockException extends Exception
{
    use RenderAble;

    public function __construct($message)
    {
        parent::__construct(
            $this->message = $message
        );
    }
}
Related