errors as $code => $error) { $exception->withError($code, current($error)); } $exception->wpError = $wpError; return $exception; } public function getWpError(): WP_Error { return $this->wpError; } }