Skip to content

Commit fe56976

Browse files
author
Alistair Kearney
committed
Updated ControllerNotFoundException and MethodNotAllowedException to extend the new AbstractApiException class
1 parent abe418d commit fe56976

2 files changed

Lines changed: 29 additions & 1 deletion

File tree

src/Lib/Exceptions/ControllerNotFoundException.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
namespace Symphony\ApiFramework\Lib\Exceptions;
44

5-
class ControllerNotFoundException extends \Exception
5+
use Symphony\ApiFramework\Lib;
6+
use Symfony\Component\HttpFoundation\Response;
7+
8+
class ControllerNotFoundException extends Lib\AbstractApiException
69
{
10+
public function __construct($controller, $code = 0, Exception $previous = null) {
11+
parent::__construct(Response::HTTP_NOT_FOUND, "Controller '{$controller}' could not be located.", $code, $previous);
12+
}
713
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
namespace Symphony\ApiFramework\Lib\Exceptions;
4+
5+
use Symphony\ApiFramework\Lib;
6+
use Symfony\Component\HttpFoundation\Response;
7+
8+
class MethodNotAllowedException extends Lib\AbstractApiException
9+
{
10+
public $method;
11+
12+
public function getHttpMethod() {
13+
return $this->method;
14+
}
15+
16+
public function __construct($method, $code = 0, Exception $previous = null) {
17+
// Save the method
18+
$this->method = $method;
19+
20+
parent::__construct(Response::HTTP_METHOD_NOT_ALLOWED, "Method '{$this->method}' is not allowed by this endpoint.", $code, $previous);
21+
}
22+
}

0 commit comments

Comments
 (0)