Exception.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /**
  3. * Exception for HTTP requests
  4. *
  5. * @package Requests
  6. */
  7. /**
  8. * Exception for HTTP requests
  9. *
  10. * @package Requests
  11. */
  12. class Requests_Exception extends Exception {
  13. /**
  14. * Type of exception
  15. *
  16. * @var string
  17. */
  18. protected $type;
  19. /**
  20. * Data associated with the exception
  21. *
  22. * @var mixed
  23. */
  24. protected $data;
  25. /**
  26. * Create a new exception
  27. *
  28. * @param string $message Exception message
  29. * @param string $type Exception type
  30. * @param mixed $data Associated data
  31. * @param integer $code Exception numerical code, if applicable
  32. */
  33. public function __construct($message, $type, $data = null, $code = 0) {
  34. parent::__construct($message, $code);
  35. $this->type = $type;
  36. $this->data = $data;
  37. }
  38. /**
  39. * Like {@see getCode()}, but a string code.
  40. *
  41. * @codeCoverageIgnore
  42. * @return string
  43. */
  44. public function getType() {
  45. return $this->type;
  46. }
  47. /**
  48. * Gives any relevant data
  49. *
  50. * @codeCoverageIgnore
  51. * @return mixed
  52. */
  53. public function getData() {
  54. return $this->data;
  55. }
  56. }