b2r/exception

b2r Exception Component

v0.3.0 2017-03-09 04:41 UTC

This package is not auto-updated.

Last update: 2024-04-13 17:41:16 UTC


README

Common exceptions in my library

Build Status

  • All exception implements ExceptionInterface
  • All exception uses ExceptionTrait
  • CHANGELOG
  • Packagist

Exception classes

  • Exception
    • InvalidClassMemberException
      • InvalidMethodException
      • InvalidPropertyException
    • InvalidIndexException
    • InvalidKeyException
    • InvalidTypeException
      • InvalidParameterTypeException
    • IOException
      • FileNotFoundException
      • DirectoryNotFoundException
    • NameException
  • InvalidArgumentException
  • LogicException
  • RuntimeException
  • ValidationException

Utility/Helper classes

  • Utils: Utility functions
  • Finder: Lookup/resolve class name

InvalidTypeException sample

use b2r\Component\Exception\InvalidTypeException;

$e = new InvalidTypeException('$key', 'string|int', []); // Variable name, Valid type, Invalid type value
echo $e->message; #=>"$key must be of the type `string|int`, but `array` given"

Finder sample

Finder lookup/resolve class name easily.

use b2r\Component\Exception\Finder as E;

$e = E::Type(); #=>'b2r\Component\Exception\InvalidTypeException'
throw new $e('name', 'string|int', null);