Coder Social home page Coder Social logo

Comments (5)

jasonyin avatar jasonyin commented on June 7, 2024

The API return two structs, one is response, the other one is err. Would the err works for you?

func (client ComputeClient) AttachVolume(ctx context.Context, request AttachVolumeRequest) (response AttachVolumeResponse, err error)

from oci-go-sdk.

MadalinaPatrichi avatar MadalinaPatrichi commented on June 7, 2024

The status code of the request is not easily extracted from the error. This used to be available in the response, but it seems like there was an API change. Is this documented anywhere to explain why this has happened and what is the recommended way of extracting the status code in the case of an error. Is this a bug or a feature?

from oci-go-sdk.

eginez avatar eginez commented on June 7, 2024

@MadalinaPatrichi. You have a couple of options

  • All API respond with an struct and an error type. The error could be an ServiceError in that case you can access the http status code from the type via the GetHTTPStatusCode(). There are other methods in the ServiceError interface you can use. Additionally if the response is not nil, all xxxResponse structs contain the RawResponse field of type http.Response where you can inspect all the details of an http response.
  • When the response is nil, then the error is not of type ServiceError and usually means that an error happened before we could execute the network call, errors in the network, marshalling errors, etc fall under that category. Those errors obviously won't have a status code.

You can see some examples of error handling here: https://github.com/oracle/oci-go-sdk/blob/master/example/example_core_test.go#L369

By the sounds of it, it seems like the error you are getting might be client related, and for the record the API to deal with these issues has not changed. Out of curiosity what is the value of your err.String()

from oci-go-sdk.

jasonyin avatar jasonyin commented on June 7, 2024

@MadalinaPatrichi , please let us know if you are still having the issue or not, otherwise, we are going to close it, thanks!

from oci-go-sdk.

jasonyin avatar jasonyin commented on June 7, 2024

@MadalinaPatrichi I am closing this issue, please let us know if you still have questions, thanks!

from oci-go-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.