Automattic\WooCommerce\StoreApi\Routes\V1\Agentic

Error::get_http_status_codeprivateWC 1.0

Determine HTTP status code based on error type.

Method of the class: Error{}

No Hooks.

Returns

Int. HTTP status code

Usage

// private - for code of main (parent) class only
$result = $this->get_http_status_code();

Error::get_http_status_code() code WC 10.7.0

private function get_http_status_code() {
	switch ( $this->type ) {
		case ErrorType::INVALID_REQUEST:
			return 400;
		case ErrorType::REQUEST_NOT_IDEMPOTENT:
			return 409;
		case ErrorType::PROCESSING_ERROR:
			return 500;
		case ErrorType::SERVICE_UNAVAILABLE:
			return 503;
		default:
			return 500;
	}
}