Skip to content

Commit f96fd85

Browse files
author
Alistair Kearney
committed
Added new abstract extension 'AbstractApiException' which is used by ControllerNotFoundException and MethodNotAllowedException. Allows setting of HTTP response code to avoid every exception thrown appearing as a '500 Internal Server Error'
1 parent a5bed6c commit f96fd85

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

src/Lib/AbstractApiException.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace Symphony\ApiFramework\Lib;
4+
5+
class AbstractApiException extends \Exception
6+
{
7+
private $status;
8+
9+
public function getHttpStatusCode() {
10+
return $this->status;
11+
}
12+
13+
public function __construct($status, $message, $code = 0, Exception $previous = null) {
14+
// Save the status code
15+
$this->status = $status;
16+
17+
parent::__construct($message, $code, $previous);
18+
}
19+
}

0 commit comments

Comments
 (0)