WC_Data_Exception

WC_Data_Exception class.

Defined (1)

The class is defined in the following location(s).

/includes/class-wc-data-exception.php  
  1. class WC_Data_Exception extends Exception { 
  2.  
  3. /** 
  4. * Sanitized error code. 
  5. * @var string 
  6. */ 
  7. protected $error_code; 
  8.  
  9. /** 
  10. * Error extra data. 
  11. * @var array 
  12. */ 
  13. protected $error_data; 
  14.  
  15. /** 
  16. * Setup exception. 
  17. * @param string $code Machine-readable error code, e.g `woocommerce_invalid_product_id`. 
  18. * @param string $message User-friendly translated error message, e.g. 'Product ID is invalid'. 
  19. * @param int $http_status_code Proper HTTP status code to respond with, e.g. 400. 
  20. * @param array $data Extra error data. 
  21. */ 
  22. public function __construct( $code, $message, $http_status_code = 400, $data = array() ) { 
  23. $this->error_code = $code; 
  24. $this->error_data = array_merge( array( 'status' => $http_status_code ), $data ); 
  25.  
  26. parent::__construct( $message, $http_status_code ); 
  27.  
  28. /** 
  29. * Returns the error code. 
  30. * @return string 
  31. */ 
  32. public function getErrorCode() { 
  33. return $this->error_code; 
  34.  
  35. /** 
  36. * Returns error data. 
  37. * @return array 
  38. */ 
  39. public function getErrorData() { 
  40. return $this->error_data;