AloFramework Handlers 2.0 API
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Todo

Namespaces

  • AloFramework
    • Handlers
      • Config
      • Output
        • Styles
  • PHP

Classes

  • AbstractHandler
  • Error
  • ErrorHandler
  • ExceptionHandler
  • ShutdownHandler

Class ErrorHandler

Handles PHP errors

AloFramework\Handlers\AbstractHandler implements AloFramework\Config\Configurable uses AloFramework\Config\ConfigurableTrait (not available)
Extended by AloFramework\Handlers\ErrorHandler
Namespace: AloFramework\Handlers
Author: Art a.molcanovas@gmail.com
Since:

1.2 Tracks the last reported error
1.1 log() accepts the $file and $line parameters


Located at class/ErrorHandler.php

Methods summary

public
# __construct( Psr\Log\LoggerInterface $logger = null, AloFramework\Handlers\Config\ErrorConfig $cfg = null )

Constructor

Constructor

Parameters

$logger
If provided, this will be used to log exceptions.
$cfg
The configuration class

Author

Art a.molcanovas@gmail.com

Since

1.4 $cfg added. This will become the first parameter in the constructor in 2.0

Overrides

AloFramework\Handlers\AbstractHandler::__construct
public static boolean
# isRegistered( )

Checks whether the handler has been registered

Checks whether the handler has been registered

Returns

boolean

Author

Art a.molcanovas@gmail.com
public static AloFramework\Handlers\ErrorHandler|null
# getLastRegisteredHandler( )

Returns the last registered handler

Returns the last registered handler

Returns

AloFramework\Handlers\ErrorHandler|null

Author

Art a.molcanovas@gmail.com

Since

1.2
public static AloFramework\Handlers\Error|null
# getLastReportedError( )

Returns the last reported error

Returns the last reported error

Returns

AloFramework\Handlers\Error|null
The last reported error or NULL if none have been reported

Author

Art a.molcanovas@gmail.com

Since

1.2
public static AloFramework\Handlers\ErrorHandler
# register( Psr\Log\LoggerInterface $logger = null, AloFramework\Handlers\Config\ErrorConfig $cfg = null )

Registers the error handler

Registers the error handler

Parameters

$logger
If provided, this will be used to log errors and exceptions.
$cfg
Your custom configuration settings

Returns

AloFramework\Handlers\ErrorHandler
The created handler

Author

Art a.molcanovas@gmail.com

Since

1.4 $cfg parameter added
1.0.4 Checks what class has called the method instead of explicitly registering ErrorHandler - allows easy class extendability.


public integer
# getErrorReporting( )

Returns what errors are being reported

Returns what errors are being reported

Returns

integer

Author

Art a.molcanovas@gmail.com
public
# handle( integer $errno, string $errstr, string $errfile, integer $errline )

The error handler

The error handler

Parameters

$errno
The level of the error raised
$errstr
The error message
$errfile
The filename that the error was raised in
$errline
The line number the error was raised at

Author

Art a.molcanovas@gmail.com

Since

1.2 Tracks the last reported error

Codecoverageignore

protected
# handleCLI( string $type, string $label, integer $errno, string $errstr, string $errfile, integer $errline )

Generates console output for errors

Generates console output for errors

Parameters

$type
Error type
$label
Error colour code ("e" for error, "w" for warning, "i" for info)
$errno
Error code
$errstr
Error message
$errfile
File where the error occurred
$errline
Line where the error occurred

Author

Art a.molcanovas@gmail.com

Codecoverageignore

protected
# handleHTML( string $type, string $label, integer $errno, string $errstr, string $errfile, integer $errline )

Generates HTML output for errors

Generates HTML output for errors

Parameters

$type
Error type
$label
Error label ("danger", "info" or "warning")
$errno
Error code
$errstr
Error message
$errfile
File where the error occurred
$errline
Line where the error occurred

Author

Art a.molcanovas@gmail.com
protected
# log( integer $errcode, string $errstr, string $file = null, integer $line = null )

Logs an error

Logs an error

Parameters

$errcode
The error's code
$errstr
The error message
$file
File where the error occurred
$line
Line number where the error occurred

Author

Art a.molcanovas@gmail.com

Since

1.1 Accepts the $file and $line parameters
public string
# __toString( )

Returns a string representation of the handler

Returns a string representation of the handler

Returns

string

Author

Art a.molcanovas@gmail.com

Overrides

AloFramework\Handlers\AbstractHandler::__toString

Methods inherited from AloFramework\Handlers\AbstractHandler

getTrace(), injectCSS()

Constants summary

Constants inherited from AloFramework\Handlers\AbstractHandler

EOL

Properties summary

Properties inherited from AloFramework\Handlers\AbstractHandler

$console, $isCLI, $logger

Magic properties

public AloFramework\Handlers\Config\ErrorConfig $config

Handler configuration

AloFramework Handlers 2.0 API API documentation generated by ApiGen