pmorie / osb-broker-lib

A go library for developing an Open Service Broker
Apache License 2.0
28 stars 23 forks source link

We need a first class way to return OSB errors back to the handler to return the correct http error to the platform #35

Closed n3wscott closed 6 years ago

n3wscott commented 6 years ago

Current code example is this:

response, err := s.Broker.Provision(request, c)
    if err != nil {
        s.writeError(w, err, http.StatusInternalServerError)
        return
    }

I have no option to return a bad args error or similar error. Perhaps we wrap error returned from the logic methods with some way to tell the handler method to return OSB errors and we can grab the description from the error returned or something.

shawn-hurley commented 6 years ago

I agree, the library should have semantic meaning for certain type of errors that the handler understands and can then return the correct error responses.

n3wscott commented 6 years ago

Oh! maybe it is fixed? https://github.com/pmorie/osb-broker-lib/pull/27

n3wscott commented 6 years ago

Not fixed yet. #27 was a good first start.

n3wscott commented 6 years ago

This works and is good enough for me:

                return nil, osb.HTTPStatusCodeError{
                    StatusCode:   http.StatusBadRequest,
                    ErrorMessage: strPtr("InvalidParameters"),
                }