Custom Exceptions

When you need to throw an exception, you should 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 are errors which are handled in a central error handler that will stop the execution. Do not use exceptions as events to control the workflow. Only expected exceptions are caught, for instance when you deal with external systems or when you must guarantee the execution (e.g. 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;
class KeyExistsException extends \Exception