Skip to content

Commit e0dd985

Browse files
authored
Merge pull request #4 from karim-elshendy/exception_response_http_status_code
make it possible to return exception error response with http status code 200
2 parents 0d73b8c + bb32ee8 commit e0dd985

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

src/Exception/ApiResponseException.php

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace MattJanssen\ApiResponseBundle\Exception;
44

55
use Symfony\Component\HttpFoundation\Response;
6+
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
67

78
/**
89
* Exception for a Failed API Response
@@ -13,7 +14,7 @@
1314
*
1415
* @author Matt Janssen <matt@mattjanssen.com>
1516
*/
16-
class ApiResponseException extends \Exception implements ApiResponseExceptionInterface
17+
class ApiResponseException extends \Exception implements HttpExceptionInterface, ApiResponseExceptionInterface
1718
{
1819
/**
1920
* HTTP Response Status Code
@@ -93,4 +94,24 @@ public function setErrorData($errorData)
9394
{
9495
$this->errorData = $errorData;
9596
}
97+
98+
/**
99+
* Returns the status code.
100+
*
101+
* @return int An HTTP response status code
102+
*/
103+
public function getStatusCode()
104+
{
105+
return $this->getHttpStatusCode();
106+
}
107+
108+
/**
109+
* Returns response headers.
110+
*
111+
* @return array Response headers
112+
*/
113+
public function getHeaders()
114+
{
115+
return [];
116+
}
96117
}

0 commit comments

Comments
 (0)