abujehad139 / google-api-go-client

Automatically exported from code.google.com/p/google-api-go-client
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Errors from server not handled well #50

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I suspect this is true about many/all services, but my code looks something 
like this:

        _, err = service.Objects.Insert(bucket, obj).Media(f).Do()

Where service is a "storage service" instance.  This is all well and good until 
the server returns an error.  The error comes through as an XML body of the 
HTTP response.  Like this:

<?xml version='1.0' 
encoding='UTF-8'?><Error><Code>NoSuchBucket</Code><Message>The specified bucket 
does not exist.</Message></Error>

The google-api-go-client tries to parse this as a valid "insert" response, and 
gets confused, giving something along the lines of:

googleapi: got HTTP response code 404 and error reading body: invalid character 
'<' looking for beginning of value: error uploading file

It would be nice if the error returned contained more information about what 
the server says the error is.

Original issue reported on code.google.com by gmil...@amilarcap.com on 13 Dec 2013 at 3:45