Skip to content

Base exception #67

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 4, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
### Added

- Added back `Http\Discovery\NotFoundException` to preserve BC with 0.8 version
- Added interface `Http\Discovery\Exception` which is implemented by all our exceptions

### Changed

Expand Down
12 changes: 12 additions & 0 deletions src/Exception.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace Http\Discovery;

/**
* An interface implemented by all discovery related exceptions.
*
* @author Tobias Nyholm <[email protected]>
*/
interface Exception
{
}
4 changes: 3 additions & 1 deletion src/Exception/DiscoveryFailedException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

namespace Http\Discovery\Exception;

use Http\Discovery\Exception;

/**
* Thrown when all discovery strategies fails to find a resource.
*
* @author Tobias Nyholm <[email protected]>
*/
final class DiscoveryFailedException extends \Exception
final class DiscoveryFailedException extends \Exception implements Exception
{
/**
* @var array
Expand Down
4 changes: 3 additions & 1 deletion src/Exception/NotFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

namespace Http\Discovery\Exception;

use Http\Discovery\Exception;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should the interface itself not live in the exception namespace?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I followed the example in HTTPlug: https://github.com/php-http/httplug/tree/master/src

I did some (very little) research and it seams that (a few) others are doing the same.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exception\Exception sounds weird, also, the inheritance is also reflected in the naming this way, which seems to be logical to me.


/**
* Thrown when a discovery does not find any matches.
*
* @final do NOT extend this class, not final for BC reasons
*
* @author Márk Sági-Kazár <[email protected]>
*/
/*final */class NotFoundException extends \RuntimeException
/*final */class NotFoundException extends \RuntimeException implements Exception
{
}
4 changes: 3 additions & 1 deletion src/Exception/StrategyUnavailableException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

namespace Http\Discovery\Exception;

use Http\Discovery\Exception;

/**
* This exception is thrown when we cannot use a discovery strategy. This is *not* thrown when
* the discovery fails to find a class.
*
* @author Tobias Nyholm <[email protected]>
*/
class StrategyUnavailableException extends \RuntimeException
class StrategyUnavailableException extends \RuntimeException implements Exception
{
}