CHAPTER 13SPL Exceptions

The SPL provides a number of built-in exception base classes that are designed to handle everyday scenarios. In this chapter, you will learn about the base exception classes, when to apply them, and how to extend them for your own requirements.

Logic Exceptions

The SPL has two central classes of exceptions: LogicException and RuntimeException (discussed in the next section). The LogicException class descends from Exception directly, and does not add any additional methods.

class LogicException extends Exception

The purpose of this classification is to allow you to differentiate between compile-time logical exceptions and exceptions caused by bad data being passed to the application.

Invoking a logic exception is just ...

Get Pro PHP: Patterns, Frameworks, Testing and More now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.