HttpInformationalException
Since v2.0.0
Description
HttpInformationalException
is an interface. It is implemented by any exception that maps onto any of the HTTP 1xx status values.
Public Interface
HttpInformationalException
has the following public interface:
// HttpInformationalException lives in this namespace
namespace GanbaroDigital\HttpStatus\Interfaces;
// our base interfaces
use GanbaroDigital\HttpStatus\Interfaces\HttpException;
// our return types
use GanbaroDigital\HttpStatus\Interfaces\HttpStatus;
interface HttpInformationalException extends HttpException
{
/**
* returns the HTTP status code that best represents this object
*
* @return HttpStatus
* @inheritedFrom HttpStatusProvider
*/
public function getHttpStatus();
}
How To Use
In Your Own Exceptions
Implement HttpInformationalException
in any exceptions that map onto a HTTP 1xx status value. Combine it with one of the status provider traits to quickly and easily add the getHttpStatus()
method that HttpInformationalException
requires:
use GanbaroDigital\HttpStatus\Interfaces\HttpInformationalException;
use GanbaroDigital\HttpStatus\StatusProviders\Informational\ContinueStatusProvider;
use RuntimeException;
class MyException extends HttpInformationalException
{
// adds getHttpStatus()
// returns a HttpStatus value object of 100 Continue
use ContinueStatusProvider;
}
try {
// ...
}
catch (HttpInformationalException $e) {
$httpStatus = $e->getHttpStatus();
// ...
}
Notes
None at this time.
See Also
- Status provider traits - helpers to provide the
getHttpStatus()
method HttpException
- base interface