In ServiceException, there are two immediately obvious ways to
obtain a concise (as opposed to stack trace level) detail message
regarding the underlying error which generated the exception:
getMessage() (derived from ServiceException's parent Exception class)
and getResponseBody().
The problem we're encountering - in the context of using the Java
Client library to access Google Calendar - is that the messages
returned by these two methods are different. It would be extremely
helpful if getMessage() were to return more detailed information than
it currently does, incorporating any messages currently provided by
getResponseBody().
Example, when accessing a Google Calendar that is not shared and
none of whose events are public, when using a visibility value of
'public' in the feed URL in the GET request and not authenticating,
the following values are returned:
ServiceException.getMessage():
Not Found
ServiceException.getResponseBody():
[... lots of HTML markup omitted here ...]
<blockquote> Cannot access the calendar you requested </blockquote>
[... more markup omitted here ...]
The second message above is considerably more specific and helpful.
At the very least, it would be desirable to have getMessage() return a
concatenation of those error responses, something akin to:
Not Found: Cannot access the calendar you requested
Since we've only worked with the Java client library in a Google
Calendar context, I don't know whether this issue may be broadly
applicable to ServiceException messages throughout the library or just
to messages returned from Calendar-specific exception messages.
Generically, however, a Java developer using the client library should
be able to rely on the fact that ServiceException.getMessage() will
provide a developer-meaningful - and if at all possible, a customer-
meaningful - error message, that doesn't omit any information that is
provided through getResponseBody() or otherwise. Thanks!
In that thread, Kyle Marvin wrote:
If you could also log the value of ServiceException.getResponseBody()
when you encounter a ServiceException, this could be helpful. This
will contain the body of the HTTP error response that was sent back
from the server and might contain additional information that could
help to narrow down the problem.
This clearly indicates that there is status information returned by
ServiceException. getResponseBody() that is not returned in any other
way.
Note that the status information returned by getResponseBody() is a
verbose
HTML block, with a myriad of tags and even embedded CSS style data.
The actual status message is a small part of that block, and could
easily
be returned separately in ServiceException.getMessage() or otherwise.
Also, the HTLM block returned from getResponseBody(), while valid
HTML 4.0.1, is not valid XHTML, so it can't easily be parsed via an
XML
parser without further modification. That makes it more challenging
to
extract just the actual status message from the block.
Cheers,
-Ryan
On Apr 6, 12:14 pm, "Aron" <aronrobe...@gmail.com> wrote:
> This thread is also relevant to the discussion:
>
> http://groups.google.com/group/google-calendar-help-dataapi/browse_th...