ParserException.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace Aws\Api\Parser\Exception;
  3. use Aws\HasMonitoringEventsTrait;
  4. use Aws\MonitoringEventsInterface;
  5. use Aws\ResponseContainerInterface;
  6. use Psr\Http\Message\ResponseInterface;
  7. class ParserException extends \RuntimeException implements
  8. MonitoringEventsInterface,
  9. ResponseContainerInterface
  10. {
  11. use HasMonitoringEventsTrait;
  12. private $errorCode;
  13. private $requestId;
  14. private $response;
  15. public function __construct($message = '', $code = 0, $previous = null, array $context = [])
  16. {
  17. $this->errorCode = isset($context['error_code']) ? $context['error_code'] : null;
  18. $this->requestId = isset($context['request_id']) ? $context['request_id'] : null;
  19. $this->response = isset($context['response']) ? $context['response'] : null;
  20. parent::__construct($message, $code, $previous);
  21. }
  22. /**
  23. * Get the error code, if any.
  24. *
  25. * @return string|null
  26. */
  27. public function getErrorCode()
  28. {
  29. return $this->errorCode;
  30. }
  31. /**
  32. * Get the request ID, if any.
  33. *
  34. * @return string|null
  35. */
  36. public function getRequestId()
  37. {
  38. return $this->requestId;
  39. }
  40. /**
  41. * Get the received HTTP response if any.
  42. *
  43. * @return ResponseInterface|null
  44. */
  45. public function getResponse()
  46. {
  47. return $this->response;
  48. }
  49. }