ClearBlade / go-iot

Apache License 2.0
3 stars 3 forks source link

two kinds of googleapis are used and WrapError doesn't return apierror.APIError #15

Closed ledmonster closed 1 year ago

ledmonster commented 1 year ago

While iot.go uses

cblib.gensupport uses

Because of this problem, gensupports' WrapError doesn't return apierror.APIError. Following test faiils.

call := c.iot.Projects.Locations.Registries.Devices.Get(c.devicePath(deviceID)).Context(c.ctx)
_, err := call.Do()
e, ok := err.(*apierror.APIError)
if !ok {
    t.Fatalf("expect apierror.APIError type. err: %v", err)
}

Please use either of these two module.

ledmonster commented 1 year ago

It seems that I misunderstood. call.Do() doesn't return googleapi.Error. It returns custom error generated here.

But I think it's still confusing.

andrewhdev commented 1 year ago

Thank you for taking the time to open this ticket.

I'd like to clarify a couple of things about your request:

ledmonster commented 1 year ago

Did this test previously work with Google's iot core sdk, but now fails when using ClearBlade's sdk?

following test works with Google's iot core sdk (google.golang.org/api v0.107.0).

call := c.iot.Projects.Locations.Registries.Devices.Get(c.devicePath(deviceID)).Context(c.ctx)
_, err := call.Do()
e, ok := err.(*googleapi.Error)
if !ok {
    t.Fatal("expect googleapi.Error type")
}

call.Do() returns googleapi.Error. (not apierror.APIError).

On the other hand, clearblade implementation returns errors.New(..) object.

Are you requesting a specific change to the call.Do() error response or an improvement to our documentation about errors?

I request two things.

andrewhdev commented 1 year ago

Thank you for the clarifications. I'll keep you updated on the progress of these changes.

andrewhdev commented 1 year ago

@ledmonster I have opened this PR to hopefully resolve your issue: https://github.com/ClearBlade/go-iot/pull/16

You can install this change to your project using the command: go get github.com/clearblade/go-iot@1073122042397cac3d11cd104739dfcecfc7b333

Would you please verify that this change works as you are expecting?

ledmonster commented 1 year ago

@andrewhdev it works fine, thank you!!