salvador98's avatar

custom exception in lumen

hi . how i can make custom exception ? i use this but not work

<?php

namespace App\Exceptions;


use Exception;

class RobotException extends Exception
{


    public function render()
    {
        return response(['error' => 'my error msg'], 422);
    }
}

$router->get('/', function () use ($router) {
    throw new \App\Exceptions\RobotException();
});

0 likes
3 replies
bobbybouwmann's avatar

Mmh this should work just fine. What kind of response do you get now?

1 like
salvador98's avatar
Whoops, looks like something went wrong.
(1/1) RobotException
in web.php line 7

I also used dd('test') inside the render function but the output did not change.

1 like
rf_dev's avatar

I am getting same issue in Lumen 5.6*. Any update here?

Please or to participate in this conversation.