Index: src/wp-includes/class-oembed.php
===================================================================
--- src/wp-includes/class-oembed.php	(revisione 35561)
+++ src/wp-includes/class-oembed.php	(copia locale)
@@ -19,6 +19,10 @@
  */
 class WP_oEmbed {
 	public $providers = array();
+	public $errors = array();
+	public $xml_errors = null;
+	public $response_body = '';
+
 	/**
 	 * @static
 	 * @var array
@@ -427,12 +431,21 @@
 		/** This filter is documented in wp-includes/class-oembed.php */
 		$args = apply_filters( 'oembed_remote_get_args', array(), $provider_url_with_args );
 
+		/*** Reset any previous errors */
+		$this->errors = array();
+		$this->xml_errors = null;
+
 		$response = wp_safe_remote_get( $provider_url_with_args, $args );
-		if ( 501 == wp_remote_retrieve_response_code( $response ) )
+		if ( 501 == wp_remote_retrieve_response_code( $response ) ) {
+			$this->errors[] = 'not-implemented';
 			return new WP_Error( 'not-implemented' );
-		if ( ! $body = wp_remote_retrieve_body( $response ) )
+		}
+		if ( ! $body = wp_remote_retrieve_body( $response ) ) {
+			$this->errors[] = 'empty-response-body';
 			return false;
+		}
 		$parse_method = "_parse_$format";
+		$this->response_body = $body;
 		return $this->$parse_method( $body );
 	}
 
@@ -446,8 +459,11 @@
 	 * @return object|false
 	 */
 	private function _parse_json( $response_body ) {
-		$data = json_decode( trim( $response_body ) );
-		return ( $data && is_object( $data ) ) ? $data : false;
+		$parse_results = ( ( $data = json_decode( trim( $response_body ) ) ) && is_object( $data ) ) ? $data : false;
+		if ( empty( $parse_results ) ) {
+			$this->errors[] = 'parse-json-failed';
+		}
+		return $parse_results;
 	}
 
 	/**
@@ -468,9 +484,16 @@
 
 		$return = $this->_parse_xml_body( $response_body );
 
+		$xml_errors = libxml_get_errors();
+
 		libxml_use_internal_errors( $errors );
 		libxml_disable_entity_loader( $loader );
 
+		if ( empty( $return ) ) {
+			$this->errors[] = 'parse-xml-failed';
+			$this->xml_errors = $xml_errors;
+		}
+
 		return $return;
 	}
 
