cURL.php 918 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. class Requests_Exception_Transport_cURL extends Requests_Exception_Transport {
  3. const EASY = 'cURLEasy';
  4. const MULTI = 'cURLMulti';
  5. const SHARE = 'cURLShare';
  6. /**
  7. * cURL error code
  8. *
  9. * @var integer
  10. */
  11. protected $code = -1;
  12. /**
  13. * Which type of cURL error
  14. *
  15. * EASY|MULTI|SHARE
  16. *
  17. * @var string
  18. */
  19. protected $type = 'Unknown';
  20. /**
  21. * Clear text error message
  22. *
  23. * @var string
  24. */
  25. protected $reason = 'Unknown';
  26. public function __construct($message, $type, $data = null, $code = 0) {
  27. if ($type !== null) {
  28. $this->type = $type;
  29. }
  30. if ($code !== null) {
  31. $this->code = $code;
  32. }
  33. if ($message !== null) {
  34. $this->reason = $message;
  35. }
  36. $message = sprintf('%d %s', $this->code, $this->reason);
  37. parent::__construct($message, $this->type, $data, $this->code);
  38. }
  39. /**
  40. * Get the error message
  41. */
  42. public function getReason() {
  43. return $this->reason;
  44. }
  45. }