1: <?php
2:
3: namespace CHEZ14\ApiKit\Controllers;
4:
5: use App\Controllers\BaseController;
6: use CHEZ14\ApiKit\Exceptions\ApiException;
7: use CodeIgniter\API\ResponseTrait;
8:
9: class DumbController extends BaseController
10: {
11: use ResponseTrait;
12:
13: /**
14: * Helps filter to throw HTTP Errors by API Exception
15: *
16: * @param ApiException $e The exception needs to be presented
17: * @return void
18: */
19: public function throwError(ApiException $e)
20: {
21: $data = [
22: "status" => false,
23: "message" => $e->getMessage(),
24: "data" => null
25: ];
26:
27: // TODO: Throw more information when we're in Dev mode;
28:
29: $this->respond($data, $e->getHttpCode())->send();
30: }
31: }
32: