ApiRequestException.php 892 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace Opentalent\OtTemplating\Exception;
  3. use Exception;
  4. /**
  5. * Class ApiRequestException
  6. *
  7. * An ApiRequestException is raised when a request to the
  8. * Opentalent Api did not return a valid answer.
  9. *
  10. * @package Opentalent\OtTemplating\Exception
  11. */
  12. class ApiRequestException extends Exception
  13. {
  14. /**
  15. * ApiRequestException constructor.
  16. *
  17. * @param $message
  18. * @param int $code
  19. * @param Exception|null $previous
  20. */
  21. public function __construct($message, $code = 0, Exception $previous = null) {
  22. parent::__construct($message, $code, $previous);
  23. }
  24. /**
  25. * Construction from other exception
  26. *
  27. * @param Exception $e
  28. * @return ApiRequestException
  29. */
  30. public static function from_exception(Exception $e) {
  31. return new ApiRequestException($e->getMessage(), $e->getCode(), $e->getPrevious());
  32. }
  33. }