try { throw new Exception("Some error message", 30); //here 30 is the custom code } catch(Exception $e) { echo "The exception code is: " . $e->getCode(); }
php artisan make:exception UserNotFoundException