Skip to content

Latest commit

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

The helpful custom PHP exceptions

Latest Stable VersionTotal DownloadsLicense

This lets you catch different-layers-specific exceptions (if needed).

Installation

The best way to use this component is through the Composer:

composer require bsadnu/php-exceptions

Usage

  • You may use exceptions within the standard throwing/catching mechanism or even extend them in any way you want:
useBsadnu\Exception\Base\InvalidArgumentException;
...try {
...
} catch (InvalidArgumentException$exception) {
...
} 
useBsadnu\Exception\Base\TypeError;
...thrownewTypeError($message);
  • It is really helpful to catch either the base BaseExceptionInterface or any other. Therefore, you can control a group of exceptions. Moreover, you may add manually as many specific interfaces as you wish.

More detailed description

All exceptions used in this library implements \Bsadnu\Exception\Interfaces\BaseExceptionInterface, and extend one of the SPL extensions. This way, you have several ways of catching specific extension groups:

  1. Catch all exceptions: \Exception
  2. Catch all exceptions thrown by the library: \Bsadnu\Exception\Interfaces\BaseExceptionInterface
  3. Catch a specific SPL exception: \LogicException
  4. Catch a specific exception thrown by the library: \Bsadnu\Exception\Base\LogicException

Contributing

All feedback / bug reports / pull requests are welcome.

License

This code is licensed under the MIT License.

About

The helpful custom PHP exceptions and exception interfaces

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages