WC_API_Exception

The WooCommerce WC API Exception class.

Defined (2)

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

/includes/api/legacy/v2/class-wc-api-exception.php  
  1. class WC_API_Exception extends Exception { 
  2.  
  3. /** @var string sanitized error code */ 
  4. protected $error_code; 
  5.  
  6. /** 
  7. * Setup exception, requires 3 params: 
  8. * error code - machine-readable, e.g. `woocommerce_invalid_product_id` 
  9. * error message - friendly message, e.g. 'Product ID is invalid' 
  10. * http status code - proper HTTP status code to respond with, e.g. 400 
  11. * @since 2.2 
  12. * @param string $error_code 
  13. * @param string $error_message user-friendly translated error message 
  14. * @param int $http_status_code HTTP status code to respond with 
  15. */ 
  16. public function __construct( $error_code, $error_message, $http_status_code ) { 
  17. $this->error_code = $error_code; 
  18. parent::__construct( $error_message, $http_status_code ); 
  19.  
  20. /** 
  21. * Returns the error code 
  22. * @since 2.2 
  23. * @return string 
  24. */ 
  25. public function getErrorCode() { 
  26. return $this->error_code; 
/includes/api/legacy/v3/class-wc-api-exception.php  
  1. class WC_API_Exception extends Exception { 
  2.  
  3. /** @var string sanitized error code */ 
  4. protected $error_code; 
  5.  
  6. /** 
  7. * Setup exception, requires 3 params: 
  8. * error code - machine-readable, e.g. `woocommerce_invalid_product_id` 
  9. * error message - friendly message, e.g. 'Product ID is invalid' 
  10. * http status code - proper HTTP status code to respond with, e.g. 400 
  11. * @since 2.2 
  12. * @param string $error_code 
  13. * @param string $error_message user-friendly translated error message 
  14. * @param int $http_status_code HTTP status code to respond with 
  15. */ 
  16. public function __construct( $error_code, $error_message, $http_status_code ) { 
  17. $this->error_code = $error_code; 
  18. parent::__construct( $error_message, $http_status_code ); 
  19.  
  20. /** 
  21. * Returns the error code 
  22. * @since 2.2 
  23. * @return string 
  24. */ 
  25. public function getErrorCode() { 
  26. return $this->error_code;