1: <?php
2:
3: namespace CHEZ14\ApiKit\Exceptions;
4:
5: use CodeIgniter\Exceptions\HTTPExceptionInterface;
6: use LogicException;
7:
8: class ApiException extends LogicException implements HTTPExceptionInterface
9: {
10: protected $httpCode = 500;
11:
12: /**
13: * Return the HTTP Code thrown by this little dude.
14: *
15: * @return integer
16: */
17: public function getHttpCode(): int
18: {
19: return $this->httpCode;
20: }
21:
22: /**
23: * @param string $message Error message, will be set to `message` part.
24: * @param integer $httpCode HTTP Code to be sent to the client.
25: * @param integer $exceptionCode Exception code. Helpful for debugging things.
26: */
27: public function __construct(string $message, int $httpCode = 500, int $exceptionCode = 0)
28: {
29: parent::__construct($message, $exceptionCode);
30: $this->httpCode = $httpCode;
31: }
32: }
33: