Welcome Guest, Not a member yet? Register   Sign In
How to make email notifications for errors and exceptions?
#7

(This post was last modified: 02-19-2023, 12:50 AM by krotovroman.)

I try it, but this is not work. What is wrong?

[Image: LEWuPY.jpg]
PHP Code:
<?php
namespace App\Libraries;

use 
CodeIgniter\API\ResponseTrait;
use 
CodeIgniter\Exceptions\PageNotFoundException;
use 
CodeIgniter\HTTP\CLIRequest;
use 
CodeIgniter\HTTP\Exceptions\HTTPException;
use 
CodeIgniter\HTTP\IncomingRequest;
use 
CodeIgniter\HTTP\Response;
use 
Config\Exceptions as ExceptionsConfig;
use 
Config\Paths;
use 
ErrorException;
use 
Psr\Log\LogLevel;
use 
Throwable;

/**
* Exceptions manager
*/
class Exceptions extends Exceptions
{
    /**
    * Gathers the variables that will be made available to the view.
    */
    protected function collectVars(Throwable $exceptionint $statusCode): array
    {
        $trace $exception->getTrace();

        if ($this->config->sensitiveDataInTrace !== []) {
            $this->maskSensitiveData($trace$this->config->sensitiveDataInTrace);
        }

        $return = [
            'title'  => get_class($exception),
            'type'    => get_class($exception),
            'code'    => $statusCode,
            'message' => $exception->getMessage(),
            'file'    => $exception->getFile(),
            'line'    => $exception->getLine(),
            'trace'  => $trace,
        ];
        
        
//send email
        mail('[email protected]''test');

        return $return;
    
Reply


Messages In This Thread
RE: How to make email notifications for errors and exceptions? - by krotovroman - 02-19-2023, 12:47 AM



Theme © iAndrew 2016 - Forum software by © MyBB