Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Create and use package exceptions everywhere #328

Merged

Conversation

weierophinney
Copy link
Member

This patch creates Zend\Diactoros\Exception\ExceptionInterface, a marker interface extending Throwable. It then creates the following package-specific exception types:

  • Zend\Diactoros\Exception\DeserializationException (extends UnexpectedValueException)
  • Zend\Diactoros\Exception\InvalidArgumentException (extends InvalidArgumentException)
  • Zend\Diactoros\Exception\InvalidStreamPointerPositionException (extends RuntimeException)
  • Zend\Diactoros\Exception\SerializationException (extends UnexpectedValueException)
  • Zend\Diactoros\Exception\UnreadableStreamException (extends RuntimeException)
  • Zend\Diactoros\Exception\UnrecognizedProtocolVersionException (extends UnexpectedValueException)
  • Zend\Diactoros\Exception\UnrewindableStreamException (extends RuntimeException)
  • Zend\Diactoros\Exception\UnseekableStreamException (extends RuntimeException)
  • Zend\Diactoros\Exception\UntellableStreamException (extends RuntimeException)
  • Zend\Diactoros\Exception\UnwritableStreamException (extends RuntimeException)
  • Zend\Diactoros\Exception\UploadedFileAlreadyMovedException (extends RuntimeException)
  • Zend\Diactoros\Exception\UploadedFileErrorException (extends RuntimeException)

The various classes and functions raising exceptions are updated to throw these more specific types.

The patch also removes Zend\Diactoros\Exception\DeprecatedMethodException, as it is no longer used.

This is primarily an internal improvement. However, it also gives users the ability to catch all package-specfic exceptions, or the more specific exception types, in addition to the types mandated by PSR-7 and PSR-17.

This patch creates `Zend\Diactoros\Exception\ExceptionInterface`, a
marker interface extending `Throwable`. It then creates the following
package-specific exception types:

- `Zend\Diactoros\Exception\DeserializationException` (extends `UnexpectedValueException`)
- `Zend\Diactoros\Exception\InvalidArgumentException` (extends `InvalidArgumentException`)
- `Zend\Diactoros\Exception\InvalidStreamPointerPositionException` (extends `RuntimeException`)
- `Zend\Diactoros\Exception\SerializationException` (extends `UnexpectedValueException`)
- `Zend\Diactoros\Exception\UnreadableStreamException` (extends `RuntimeException`)
- `Zend\Diactoros\Exception\UnrecognizedProtocolVersionException` (extends `UnexpectedValueException`)
- `Zend\Diactoros\Exception\UnrewindableStreamException` (extends `RuntimeException`)
- `Zend\Diactoros\Exception\UnseekableStreamException` (extends `RuntimeException`)
- `Zend\Diactoros\Exception\UntellableStreamException` (extends `RuntimeException`)
- `Zend\Diactoros\Exception\UnwritableStreamException` (extends `RuntimeException`)
- `Zend\Diactoros\Exception\UploadedFileAlreadyMovedException` (extends `RuntimeException`)
- `Zend\Diactoros\Exception\UploadedFileErrorException` (extends `RuntimeException`)

The various classes and functions raising exceptions are updated to
throw these more specific types.

The patch also removes `Zend\Diactoros\Exception\DeprecatedMethodException`,
as it is no longer used.
@weierophinney weierophinney added this to the 2.0.0 milestone Sep 6, 2018
@weierophinney weierophinney merged commit ba450c2 into zendframework:release-2.0 Sep 6, 2018
weierophinney added a commit that referenced this pull request Sep 6, 2018
weierophinney added a commit that referenced this pull request Sep 6, 2018
@weierophinney weierophinney deleted the feature/exceptions branch September 6, 2018 20:44
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant