PHP Warning throws ErrorException - laravel

A unit test is failing because an ErrorException about an undefined property is thrown. However, this happens in a connected shop system's core files which i cannot change.
My controller has a try ... catch block that catches the generic Exception object. But i don't want that catch to fire because of an undefined property.
I figured out the error is converted to an ErrorException in HandleExceptions.php in method handleError
How can i make phpunit ignore notices and warnings coming from code pieces i can't touch?
What i've already tried
In phpunit.xml
convertErrorsToExceptions="false"
convertNoticesToExceptions="false"
convertWarningsToExceptions="false"
Set APP_DEBUG=false as well as API_DEBUG=false for dingo.
I am using Dingo 1.0.x with Laravel 5.4 and phpunit 5.7.26.

Related

Laravel Exceptions handling when debug=false

I use the default Laravel Exception handler, but I have a question regarding good practices.
When I have a condition in which the controller must throw an exception, I do the following:
if($blah) {
abort(500, "The user should not be here");
}
and then on the frontend, I have a view that handles the error as this:
#section('message', __($exception->getMessage() ?: 'Whoops, something went wrong on our servers.'))
So that works great as long as I have the following on the .env file:
APP_DEBUG=true
Whenever I change this value to false, (as it should in production), all I get on the error page is: Server Error instead of my custom message.
How can I keep my custom error message, and have APP_DEBUG=false in production?
If you want to customize you HTTP errors for specific views or conditions, then you will have to look into Rendering exceptions section that will show you how to show a custom view for a specific exception. With this you can throw an exception like
throw new UserNotFoundException();
and listen to that exception and render a specific view as required.

Laravel 7.x View-related exception after config:cache

I am a junior php developer and very new to laravel. I have the following problem. I cached my config with php artisan config:cache, the programm broke with error 500 and in the log i saw the exception shown bellow :
local.ERROR: Method Illuminate\View\View::__toString() must not throw an exception, caught Facade\Ignition\Exceptions\ViewException: Route [homepage.get] not defined.
(View: /var/www/vhosts/sotiris.upgrade/httpdocs/command-center/resources/views/static/includes/header.blade.php) {"exception":"[object] (Symfony\Component\ErrorHandler\Error\FatalError(code: 0): Method Illuminate\View\View::__toString() must not throw an exception, caught Facade\Ignition\Exceptions\ViewException: Route [homepage.get] not defined.
(View: /var/www/vhosts/sotiris.upgrade/httpdocs/command-center/resources/views/static/includes/header.blade.php) at /var/www/vhosts/sotiris.upgrade/httpdocs/command-center/vendor/symfony/http-foundation/Response.php:0).
I cleared everything in cache and it worked. Can anyone please help me ? Any steps?? Files to look for ? Anything

Call to undefined method Illuminate\View\Compilers\BladeCompiler::component()/

I have tried to create a Blade component in laravel 5.6. I have added this code segment Blade::component('front.components.filter','filter'); in AppServiceProvider.php and add this in my blade file
#filter #endfilter
when I try to run the program I have got this error
Call to undefined method Illuminate\View\Compilers\BladeCompiler::component()/
How can I fix this?

Paypal I am not getting login page I have redirected to paypal controller

I have got console error like this:
Failed to load resource https://www.sandbox.paypal.com/MERCHANTPAYMENTWEB-640-20140614-1/Checkout/js/min/widgets.js
Uncaught TypeError: Cannot set property 'CSS_HEADER' of undefined checkout.js:164
Uncaught TypeError: Cannot call method 'init' of undefined login.js:7
body.scrollTop is deprecated in strict mode. Please use 'documentElement.scrollTop' if in strict mode and 'body.scrollTop' only if in quirks mode.
Any body please help I am not getting
It is due to the setting error in the chrome of my computer . some unwanted apps got installed . I need reset my chrome setting .It is blocking secured information over there .
Thank you friends

Laravel 4: Whoops library and set_cookie function

I updated to the latest version of Laravel 4 using composer update. Now I'm having a problem with the error handling library it uses - Whoops. When I have an error in my code, for instance an syntax error the following happens:
I reload the page
The actual exception ('Unexpected xxxx at ...') appears for less than a second
Another exception replaces it:
Cannot modify header information - headers already sent by (output started at /Users/planewalker/Sites/jean/welper/vendor/filp/whoops/src/Whoops/Run.php:204)
The code at the above line is this:
// If we're allowed to, send output generated by handlers directly
// to the output, otherwise, return it so that it may be used by
// the caller.
if($this->writeToOutput()) {
echo $output;
}
return $output;
and more specifically the echo $output; part.
Does anyone know why this happens?
UPDATE:
I've now determined that the problem is caused by the set_cookie function in combination with the Whoops library's exception output. It seems that the set_cookie function is called after the Whoops library has started outputting its view.
The only solution I found was to use a different session driver that the 'cookie' one. I've switched to using 'native' and the problem does not appear anymore.
Have you edited the start.php or path.php for echoing debug informations. In the most cases this is the problem.
Because start.php is called before the errorhandler is called and in Laravel for every output headers are sent.
Try updating your Laravel 4:
composer update
This problem should be fixed and you would receive the first exception which is thrown.

Resources