Symfony Exception

ErrorException

HTTP 500 Internal Server Error

file_exists(): open_basedir restriction in effect. File(unknown) is not within the allowed path(s): (/home/ghafoor2/domains/filenab.com/:/tmp/:/usr/local/php-7.4/lib/php/)

Exception

ErrorException

  1.         return $this;
  2.     }
  3.     public function get(string $fileName): array
  4.     {
  5.         if (! file_exists($fileName)) {
  6.             return [];
  7.         }
  8.         try {
  9.             $file = new File($fileName);
HandleExceptions->handleError(2, 'file_exists(): open_basedir restriction in effect. File(unknown) is not within the allowed path(s): (/home/ghafoor2/domains/filenab.com/:/tmp/:/usr/local/php-7.4/lib/php/)', '/home/ghafoor2/domains/filenab.com/vendor/facade/flare-client-php/src/Stacktrace/Codesnippet.php', 31, array('fileName' => 'unknown'))
  1.         return $this;
  2.     }
  3.     public function get(string $fileName): array
  4.     {
  5.         if (! file_exists($fileName)) {
  6.             return [];
  7.         }
  8.         try {
  9.             $file = new File($fileName);
  1.     public function toArray(): array
  2.     {
  3.         $codeSnippet = (new Codesnippet())
  4.             ->snippetLineCount(31)
  5.             ->surroundingLine($this->lineNumber)
  6.             ->get($this->file);
  7.         return [
  8.             'line_number' => $this->lineNumber,
  9.             'method' => $this->method,
  10.             'class' => $this->class,
  1.     }
  2.     public function toArray(): array
  3.     {
  4.         return array_map(function (Frame $frame) {
  5.             return $frame->toArray();
  6.         }, $this->frames);
  7.     }
  8.     public function firstApplicationFrame(): ?Frame
  9.     {
Stacktrace->Facade\FlareClient\Stacktrace\{closure}(object(Frame))
  1.     public function toArray(): array
  2.     {
  3.         return array_map(function (Frame $frame) {
  4.             return $frame->toArray();
  5.         }, $this->frames);
  6.     }
  7.     public function firstApplicationFrame(): ?Frame
  8.     {
  9.         foreach ($this->frames as $index => $frame) {
  1.             'exception_class' => $this->exceptionClass,
  2.             'seen_at' => $this->getCurrentTime(),
  3.             'message' => $this->message,
  4.             'glows' => $this->glows,
  5.             'solutions' => $this->solutions,
  6.             'stacktrace' => $this->stacktrace->toArray(),
  7.             'context' => $this->allContext(),
  8.             'stage' => $this->stage,
  9.             'message_level' => $this->messageLevel,
  10.             'open_frame_index' => $this->openFrameIndex,
  11.             'group_by' => $this->groupBy ?? GroupingTypes::TOP_FRAME,
  1.         }
  2.     }
  3.     public function report(): array
  4.     {
  5.         return $this->report->toArray();
  6.     }
  7.     public function jsonEncode($data): string
  8.     {
  9.         $jsonOptions JSON_PARTIAL_OUTPUT_ON_ERROR JSON_HEX_TAG JSON_HEX_APOS JSON_HEX_AMP JSON_HEX_QUOT;
  1.             'telescopeUrl' => $this->telescopeUrl(),
  2.             'shareEndpoint' => $this->shareEndpoint(),
  3.             'title' => $this->title(),
  4.             'config' => $this->config(),
  5.             'solutions' => $this->solutions(),
  6.             'report' => $this->report(),
  7.             'housekeepingEndpoint' => url(config('ignition.housekeeping_endpoint_prefix''_ignition')),
  8.             'styles' => $this->styles(),
  9.             'scripts' => $this->scripts(),
  10.             'tabs' => $this->tabs(),
  11.             'jsonEncode' => Closure::fromCallable([$this'jsonEncode']),
  1.     protected function renderException(ErrorPageViewModel $exceptionViewModel)
  2.     {
  3.         echo $this->renderer->render(
  4.             'errorPage',
  5.             $exceptionViewModel->toArray()
  6.         );
  7.     }
  8. }
  1.             $solutions
  2.         );
  3.         $viewModel->defaultTab($defaultTab$defaultTabProps);
  4.         $this->renderException($viewModel);
  5.     }
  6.     public function handleReport(Report $report$defaultTab null$defaultTabProps = [])
  7.     {
  8.         $viewModel = new ErrorPageViewModel(
  1.     }
  2.     public function handle(): ?int
  3.     {
  4.         try {
  5.             $this->errorPageHandler->handle($this->exception);
  6.         } catch (Error $error) {
  7.             // Errors aren't caught by Whoops.
  8.             // Convert the error to an exception and throw again.
  9.             throw new ErrorException(
<?php
/**
 * Whoops - php errors for cool kids
 * @author Filipe Dobreira <http://github.com/filp>
 */

namespace Whoops;

use 
InvalidArgumentException;
use 
Throwable;
use 
Whoops\Exception\ErrorException;
use 
Whoops\Exception\Inspector;
use 
Whoops\Handler\CallbackHandler;
use 
Whoops\Handler\Handler;
use 
Whoops\Handler\HandlerInterface;
use 
Whoops\Util\Misc;
use 
Whoops\Util\SystemFacade;

final class 
Run implements RunInterface
{
    
/**
     * @var bool
     */
    
private $isRegistered;

    
/**
     * @var bool
     */
    
private $allowQuit       true;

    
/**
     * @var bool
     */
    
private $sendOutput      true;

    
/**
     * @var integer|false
     */
    
private $sendHttpCode    500;

    
/**
     * @var HandlerInterface[]
     */
    
private $handlerStack = [];

    
/**
     * @var array
     * @psalm-var list<array{patterns: string, levels: int}>
     */
    
private $silencedPatterns = [];

    
/**
     * @var SystemFacade
     */
    
private $system;

    
/**
     * In certain scenarios, like in shutdown handler, we can not throw exceptions.
     *
     * @var bool
     */
    
private $canThrowExceptions true;

    public function 
__construct(SystemFacade $system null)
    {
        
$this->system $system ?: new SystemFacade;
    }

    
/**
     * Explicitly request your handler runs as the last of all currently registered handlers.
     *
     * @param HandlerInterface $handler
     *
     * @return Run
     */
    
public function appendHandler($handler)
    {
        
array_unshift($this->handlerStack$this->resolveHandler($handler));
        return 
$this;
    }

    
/**
     * Explicitly request your handler runs as the first of all currently registered handlers.
     *
     * @param HandlerInterface $handler
     *
     * @return Run
     */
    
public function prependHandler($handler)
    {
        return 
$this->pushHandler($handler);
    }

    
/**
     * Register your handler as the last of all currently registered handlers (to be executed first).
     * Prefer using appendHandler and prependHandler for clarity.
     *
     * @param Callable|HandlerInterface $handler
     *
     * @return Run
     *
     * @throws InvalidArgumentException If argument is not callable or instance of HandlerInterface.
     */
    
public function pushHandler($handler)
    {
        
$this->handlerStack[] = $this->resolveHandler($handler);
        return 
$this;
    }

    
/**
     * Removes and returns the last handler pushed to the handler stack.
     *
     * @see Run::removeFirstHandler(), Run::removeLastHandler()
     *
     * @return HandlerInterface|null
     */
    
public function popHandler()
    {
        return 
array_pop($this->handlerStack);
    }

    
/**
     * Removes the first handler.
     *
     * @return void
     */
    
public function removeFirstHandler()
    {
        
array_pop($this->handlerStack);
    }

    
/**
     * Removes the last handler.
     *
     * @return void
     */
    
public function removeLastHandler()
    {
        
array_shift($this->handlerStack);
    }

    
/**
     * Returns an array with all handlers, in the order they were added to the stack.
     *
     * @return array
     */
    
public function getHandlers()
    {
        return 
$this->handlerStack;
    }

    
/**
     * Clears all handlers in the handlerStack, including the default PrettyPage handler.
     *
     * @return Run
     */
    
public function clearHandlers()
    {
        
$this->handlerStack = [];
        return 
$this;
    }

    
/**
     * Registers this instance as an error handler.
     *
     * @return Run
     */
    
public function register()
    {
        if (!
$this->isRegistered) {
            
// Workaround PHP bug 42098
            // https://bugs.php.net/bug.php?id=42098
            
class_exists("\\Whoops\\Exception\\ErrorException");
            
class_exists("\\Whoops\\Exception\\FrameCollection");
            
class_exists("\\Whoops\\Exception\\Frame");
            
class_exists("\\Whoops\\Exception\\Inspector");

            
$this->system->setErrorHandler([$thisself::ERROR_HANDLER]);
            
$this->system->setExceptionHandler([$thisself::EXCEPTION_HANDLER]);
            
$this->system->registerShutdownFunction([$thisself::SHUTDOWN_HANDLER]);

            
$this->isRegistered true;
        }

        return 
$this;
    }

    
/**
     * Unregisters all handlers registered by this Whoops\Run instance.
     *
     * @return Run
     */
    
public function unregister()
    {
        if (
$this->isRegistered) {
            
$this->system->restoreExceptionHandler();
            
$this->system->restoreErrorHandler();

            
$this->isRegistered false;
        }

        return 
$this;
    }

    
/**
     * Should Whoops allow Handlers to force the script to quit?
     *
     * @param bool|int $exit
     *
     * @return bool
     */
    
public function allowQuit($exit null)
    {
        if (
func_num_args() == 0) {
            return 
$this->allowQuit;
        }

        return 
$this->allowQuit = (bool) $exit;
    }

    
/**
     * Silence particular errors in particular files.
     *
     * @param array|string $patterns List or a single regex pattern to match.
     * @param int          $levels   Defaults to E_STRICT | E_DEPRECATED.
     *
     * @return Run
     */
    
public function silenceErrorsInPaths($patterns$levels 10240)
    {
        
$this->silencedPatterns array_merge(
            
$this->silencedPatterns,
            
array_map(
                function (
$pattern) use ($levels) {
                    return [
                        
"pattern" => $pattern,
                        
"levels" => $levels,
                    ];
                },
                (array) 
$patterns
            
)
        );

        return 
$this;
    }

    
/**
     * Returns an array with silent errors in path configuration.
     *
     * @return array
     */
    
public function getSilenceErrorsInPaths()
    {
        return 
$this->silencedPatterns;
    }

    
/**
     * Should Whoops send HTTP error code to the browser if possible?
     * Whoops will by default send HTTP code 500, but you may wish to
     * use 502, 503, or another 5xx family code.
     *
     * @param bool|int $code
     *
     * @return int|false
     *
     * @throws InvalidArgumentException
     */
    
public function sendHttpCode($code null)
    {
        if (
func_num_args() == 0) {
            return 
$this->sendHttpCode;
        }

        if (!
$code) {
            return 
$this->sendHttpCode false;
        }

        if (
$code === true) {
            
$code 500;
        }

        if (
$code 400 || 600 <= $code) {
            throw new 
InvalidArgumentException(
                
"Invalid status code '$code', must be 4xx or 5xx"
            
);
        }

        return 
$this->sendHttpCode $code;
    }

    
/**
     * Should Whoops push output directly to the client?
     * If this is false, output will be returned by handleException.
     *
     * @param bool|int $send
     *
     * @return bool
     */
    
public function writeToOutput($send null)
    {
        if (
func_num_args() == 0) {
            return 
$this->sendOutput;
        }

        return 
$this->sendOutput = (bool) $send;
    }

    
/**
     * Handles an exception, ultimately generating a Whoops error page.
     *
     * @param Throwable $exception
     *
     * @return string Output generated by handlers.
     */
    
public function handleException($exception)
    {
        
// Walk the registered handlers in the reverse order
        // they were registered, and pass off the exception
        
$inspector $this->getInspector($exception);

        
// Capture output produced while handling the exception,
        // we might want to send it straight away to the client,
        // or return it silently.
        
$this->system->startOutputBuffering();

        
// Just in case there are no handlers:
        
$handlerResponse null;
        
$handlerContentType null;

        try {
            foreach (
array_reverse($this->handlerStack) as $handler) {
                
$handler->setRun($this);
                
$handler->setInspector($inspector);
                
$handler->setException($exception);

                
// The HandlerInterface does not require an Exception passed to handle()
                // and neither of our bundled handlers use it.
                // However, 3rd party handlers may have already relied on this parameter,
                // and removing it would be possibly breaking for users.
                
$handlerResponse $handler->handle($exception);

                
// Collect the content type for possible sending in the headers.
                
$handlerContentType method_exists($handler'contentType') ? $handler->contentType() : null;

                if (
in_array($handlerResponse, [Handler::LAST_HANDLERHandler::QUIT])) {
                    
// The Handler has handled the exception in some way, and
                    // wishes to quit execution (Handler::QUIT), or skip any
                    // other handlers (Handler::LAST_HANDLER). If $this->allowQuit
                    // is false, Handler::QUIT behaves like Handler::LAST_HANDLER
                    
break;
                }
            }

            
$willQuit $handlerResponse == Handler::QUIT && $this->allowQuit();
        } finally {
            
$output $this->system->cleanOutputBuffer();
        }

        
// If we're allowed to, send output generated by handlers directly
        // to the output, otherwise, and if the script doesn't quit, return
        // it so that it may be used by the caller
        
if ($this->writeToOutput()) {
            
// @todo Might be able to clean this up a bit better
            
if ($willQuit) {
                
// Cleanup all other output buffers before sending our output:
                
while ($this->system->getOutputBufferLevel() > 0) {
                    
$this->system->endOutputBuffering();
                }

                
// Send any headers if needed:
                
if (Misc::canSendHeaders() && $handlerContentType) {
                    
header("Content-Type: {$handlerContentType}");
                }
            }

            
$this->writeToOutputNow($output);
        }

        if (
$willQuit) {
            
// HHVM fix for https://github.com/facebook/hhvm/issues/4055
            
$this->system->flushOutputBuffer();

            
$this->system->stopExecution(1);
        }

        return 
$output;
    }

    
/**
     * Converts generic PHP errors to \ErrorException instances, before passing them off to be handled.
     *
     * This method MUST be compatible with set_error_handler.
     *
     * @param int         $level
     * @param string      $message
     * @param string|null $file
     * @param int|null    $line
     *
     * @return bool
     *
     * @throws ErrorException
     */
    
public function handleError($level$message$file null$line null)
    {
        if (
$level $this->system->getErrorReportingLevel()) {
            foreach (
$this->silencedPatterns as $entry) {
                
$pathMatches = (bool) preg_match($entry["pattern"], $file);
                
$levelMatches $level $entry["levels"];
                if (
$pathMatches && $levelMatches) {
                    
// Ignore the error, abort handling
                    // See https://github.com/filp/whoops/issues/418
                    
return true;
                }
            }

            
// XXX we pass $level for the "code" param only for BC reasons.
            // see https://github.com/filp/whoops/issues/267
            
$exception = new ErrorException($message/*code*/ $level/*severity*/ $level$file$line);
            if (
$this->canThrowExceptions) {
                throw 
$exception;
            } else {
                
$this->handleException($exception);
            }
            
// Do not propagate errors which were already handled by Whoops.
            
return true;
        }

        
// Propagate error to the next handler, allows error_get_last() to
        // work on silenced errors.
        
return false;
    }

    
/**
     * Special case to deal with Fatal errors and the like.
     *
     * @return void
     */
    
public function handleShutdown()
    {
        
// If we reached this step, we are in shutdown handler.
        // An exception thrown in a shutdown handler will not be propagated
        // to the exception handler. Pass that information along.
        
$this->canThrowExceptions false;

        
$error $this->system->getLastError();
        if (
$error && Misc::isLevelFatal($error['type'])) {
            
// If there was a fatal error,
            // it was not handled in handleError yet.
            
$this->allowQuit false;
            
$this->handleError(
                
$error['type'],
                
$error['message'],
                
$error['file'],
                
$error['line']
            );
        }
    }

    
/**
     * @param Throwable $exception
     *
     * @return Inspector
     */
    
private function getInspector($exception)
    {
        return new 
Inspector($exception);
    }

    
/**
     * Resolves the giving handler.
     *
     * @param HandlerInterface $handler
     *
     * @return HandlerInterface
     *
     * @throws InvalidArgumentException
     */
    
private function resolveHandler($handler)
    {
        if (
is_callable($handler)) {
            
$handler = new CallbackHandler($handler);
        }

        if (!
$handler instanceof HandlerInterface) {
            throw new 
InvalidArgumentException(
                
"Handler must be a callable, or instance of "
                
"Whoops\\Handler\\HandlerInterface"
            
);
        }

        return 
$handler;
    }

    
/**
     * Echo something to the browser.
     *
     * @param string $output
     *
     * @return Run
     */
    
private function writeToOutputNow($output)
    {
        if (
$this->sendHttpCode() && Misc::canSendHeaders()) {
            
$this->system->setHttpResponseCode(
                
$this->sendHttpCode()
            );
        }

        echo 
$output;

        return 
$this;
    }
}