Author: siwuzzz
Date: Thu May 10 19:51:59 2007
New Revision: 146
Modified:
trunk/clients/cs/RELEASE_NOTES.txt
trunk/clients/cs/src/core/exceptions.cs
trunk/clients/cs/src/gapps/appsexception.cs
Log:
Fixed a bug in GDataRequestException, and AppsException: AppsException couldn't
read the response from the server because of GDataRequestException.
Modified AppsException as well to work nicely with GDataRequestException.
Updated release notes.
Modified: trunk/clients/cs/RELEASE_NOTES.txt
==============================================================================
--- trunk/clients/cs/RELEASE_NOTES.txt (original)
+++ trunk/clients/cs/RELEASE_NOTES.txt Thu May 10 19:51:59 2007
@@ -1,3 +1,7 @@
+== 1.0.9.9 ==
+- fixed a bug in GDataRequestException that would prevent AppsException from
accessing the server's response.
+- modified AppsException to comply with new GDataRequestException
+
== 1.0.9.8 ==
- fixed a parsing bug in SpreadsheetService
Modified: trunk/clients/cs/src/core/exceptions.cs
==============================================================================
--- trunk/clients/cs/src/core/exceptions.cs (original)
+++ trunk/clients/cs/src/core/exceptions.cs Thu May 10 19:51:59 2007
@@ -207,6 +207,7 @@
/// <summary>holds the webresponse object</summary>
protected WebResponse webResponse;
+ protected string responseText;
//////////////////////////////////////////////////////////////////////
/// <summary>default constructor so that FxCop does not
complain</summary>
@@ -227,47 +228,32 @@
/// <summary>
/// this uses the webresponse object to get at the
- /// stream send back from the server and return the
- /// error message.
+ /// stream send back from the server.
/// </summary>
- public string ResponseString
+ /// <returns>the error message</returns>
+ protected string ReadResponseString()
{
- get
+ Stream responseStream = this.webResponse.GetResponseStream();
+
+ if (responseStream != null)
{
- string responseText = null;
-
- if (this.webResponse != null)
- {
- // Obtain a 'Stream' object associated with the response
object.
- Stream receiver = this.webResponse.GetResponseStream();
- if (receiver != null)
- {
- // Pipe the stream to a higher level stream reader
with the default encoding format.
- // which is UTF8
- //
- StreamReader readStream = new StreamReader(receiver);
-
- // Read 256 charcters at a time.
- char []buffer = new char[256];
- StringBuilder builder = new StringBuilder(1024);
- int count = readStream.Read( buffer, 0, 256 );
- while (count > 0)
- {
- // Dump the 256 characters on a string and display
the string onto the console.
- builder.Append(buffer);
- count = readStream.Read(buffer, 0, 256);
- }
-
- // Release the resources of stream object.
- readStream.Close();
- receiver.Close();
-
- responseText = builder.ToString();
- }
-
- }
+ StreamReader reader = new StreamReader(responseStream);
+ return (reader.ReadToEnd());
+ }
+
+ return (null);
+ }
- return responseText;
+ /// <summary>
+ /// this is the error message returned by the server
+ /// </summary>
+ public string ResponseString
+ {
+ get
+ {
+ if (this.responseText == null)
+ this.responseText = ReadResponseString();
+ return (this.responseText);
}
}
Modified: trunk/clients/cs/src/gapps/appsexception.cs
==============================================================================
--- trunk/clients/cs/src/gapps/appsexception.cs (original)
+++ trunk/clients/cs/src/gapps/appsexception.cs Thu May 10 19:51:59 2007
@@ -1,4 +1,5 @@
using System;
+using System.IO;
using System.Net;
using System.Xml;
using Google.GData.Client;
@@ -201,42 +202,27 @@
if (e != null)
{
- WebException w = e.InnerException as WebException;
- if (w != null)
- {
- HttpWebResponse response = w.Response as HttpWebResponse;
- if (response != null && response.GetResponseStream() !=
null)
- {
-
- try
+ try
+ {
+ XmlReader reader = new XmlTextReader(e.ResponseString,
XmlNodeType.Document, null);
+ // now find the ErrorElement
+ while (reader.Read())
+ if (reader.NodeType == XmlNodeType.Element &&
reader.LocalName == AppsNameTable.XmlElementError)
{
- XmlReader reader = new
XmlTextReader(response.GetResponseStream());
- // now find the ErrorElement
- while (reader.Read())
- {
- if (reader.NodeType == XmlNodeType.Element &&
reader.LocalName.Equals(AppsNameTable.XmlElementError))
- {
- break;
- }
- }
-
- if (reader.EOF == false)
- {
- result = new AppsException(e);
- result.ErrorCode =
-
reader.GetAttribute(AppsNameTable.XmlAttributeErrorErrorCode);
- result.InvalidInput =
-
reader.GetAttribute(AppsNameTable.XmlAttributeErrorInvalidInput);
- result.Reason =
-
reader.GetAttribute(AppsNameTable.XmlAttributeErrorReason);
- }
+ result = new AppsException(e);
+ result.ErrorCode =
+
reader.GetAttribute(AppsNameTable.XmlAttributeErrorErrorCode);
+ result.InvalidInput =
+
reader.GetAttribute(AppsNameTable.XmlAttributeErrorInvalidInput);
+ result.Reason =
+
reader.GetAttribute(AppsNameTable.XmlAttributeErrorReason);
+ break;
}
- catch (XmlException)
- {
- // Silently fail if we couldn't parse the XML
- }
- }
- }
+ }
+ catch (XmlException)
+ {
+
+ }
}
return result;
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Data API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/google-help-dataapi?hl=en
-~----------~----~----~----~------~----~------~--~---