Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
0.00%
0 / 1
0.00%
0 / 4
CRAP
0.00%
0 / 8
HttpErrorException
0.00%
0 / 1
0.00%
0 / 4
30
0.00%
0 / 8
 __construct( HttpProblem $httpProblem = null, $previous=null )
0.00%
0 / 1
6
0.00%
0 / 4
 factory(HttpProblem $httpProblem = null, $previous=null )
0.00%
0 / 1
2
0.00%
0 / 1
 getHttpProblem()
0.00%
0 / 1
2
0.00%
0 / 1
 __toString()
0.00%
0 / 1
2
0.00%
0 / 2
<?php
namespace BOTK\Core;
use BOTK\Core\Models\HttpProblem,
BOTK\Core\Representations\Error;
/**
* HttpError Exception
*
* This Exception a superclass for 4xx and 5xx http errors
*
*/
class HttpErrorException extends \Exception
{
protected $httpProblem;
public function __construct( HttpProblem $httpProblem = null, $previous=null )
{
if (is_null($httpProblem)) $httpProblem = new HttpProblem;
parent::__construct($httpProblem->title, $httpProblem->httpStatus, $previous);
$this->httpProblem = $httpProblem;
}
public static function factory(HttpProblem $httpProblem = null, $previous=null )
{
return new static($httpProblem, $previous );
}
final public function getHttpProblem()
{
return $this->httpProblem;
}
/**
* Redefine to string
*/
public function __toString()
{
$problem = $this->getHttpProblem();
return "$problem->title($problem->httpStatus). $problem->detail";
}
}