dhii/exception
最新稳定版本:v0.1-alpha5
Composer 安装命令:
composer require dhii/exception
包简介
Standards-compliant exception classes
README 文档
README
Standards-compliant exception classes.
Details
This package contains concrete implementations of classes that implement
interfaces in dhii/exception-interface. This provides developers with
ready-made, standards-compliant classes that can be safely instantiated and
thrown to signal the various errors. The concrete exceptions will usually
have a corresponding factory trait, and the factory methods of those traits
are the recommended way of creating new exception instances (after service
definition, of course).
Implementations in this package also have the following features aimed to become more standards-compliant:
- A stringable is accepted everywhere, where a string can be passed.
- All parameters can be passed
nullto signal default value (which may be notnull).
Consumers, i.e. code that attempts to catch, should not depend on these
classes. Instead, consumers should depend on the interfaces of
dhii/exception-interface.
Creating New Exceptions
Sometimes, there is a need to create a new exception class, such as to implement a new standard (like dhii/action-interface),
or perhaps to implement two unrelated interfaces (imagine an object that implements both Dhii\Action\ActionInterface
and Mouf\Utils\Action\ActionInterface). In this case, implementing some of the features of Dhii exceptions may
take an un-necessarily long time. This package provides a way to make creating new exceptions faster.
- If you need to extend a class other than
Exception, thenExceptionTraithelps by combining common traits used by exceptions, which will initialize the class, while normalizing some values. SeeDhii\Exception\InvalidArgumentExceptionfor an example. - If you need to extend the root
Exception, then the quickest way is by instead extendingDhii\Exception\AbstractBaseException. SeeDhii\Exception\Exceptionfor an example. As demonstrated, all basic initialization and normalization can be achieved by calling_initBaseException()in the constructor, after which custom initialization procedure may be added.
统计信息
- 总下载量: 13.95k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 21
- 推荐数: 3
其他信息
- 授权协议: MIT
- 更新时间: 2017-07-30