Custom exceptions

Edit on GitHub

To throw an exception, you need to define your own type of exception. Later, it is much easier to handle exceptions when the type represents a specific type of error.

In Spryker exceptions and errors are handled in a central error handler that doesn’t stop the execution. Do not use exceptions as events to control the workflow. Only expected exceptions are caught—for example, when you deal with external systems; or when you must guarantee the execution—for example, when you send an email in the checkout then this must not break the execution.

Usually, exceptions have an empty body and extend the global \Exception class.


namespace Pyz\Zed\Glossary\Business\Exception;

use Exception;

class KeyExistsException extends Exception