- 
                Notifications
    You must be signed in to change notification settings 
- Fork 4
enable httperror to return status code from server #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
821a9bb    to
    cec6749      
    Compare
  
    Signed-off-by: Nitishkumar Singh <[email protected]>
cec6749    to
    78dcc29      
    Compare
  
    | Branch was re-based against master branch and below script was used to run test against both   | 
| I wonder if it's obvious that error is a wrapped HTTPError that can be unwraped? func (s *Client) deploy(ctx context.Context, method string, spec types.FunctionDeployment) (int, error) {
func (s *Client) deploy(ctx context.Context, method string, spec types.FunctionDeployment) error {Would it make sense to return HTTPError instead of error given that the int has now been removed? | 
| 
 We are also returning generic error sometimes. So calling all errors as  https://github.com/openfaas/go-sdk/pull/8/files#diff-4b667feae66c9d46b21b9ecc19e8958cf4472d162ce0a47ac3e8386af8bbd8cfR219 | 
| I am not sure i understand the situation here. If the error is caused by some kind of http based error, return an HttpError, if not return the (potentially wrapped) other error.  Ideally  var httpErr *HttpError
if errors.Is(err, &httpErr) {
   // special http handling
}See https://pkg.go.dev/errors#example-As or type HttpError struct {
	Err    error
	Status int
}
func (e *HttpError) Error() string {
	return e.Err.Error()
}
func (e HttpError) Status() int {
   return e.Status
}
// Then later
type Statuser interface {
    Status() int
}
// then later
if e, ok := err.(Statuser); ok {
    fmt.Printf("we have a status code %d" e.Status())
} | 
| 
 Agree. This is what I have thought of. | 
Description
Return
HttpErrorwhich provides status code returned by openfaas API. We are only returningHttpErrorfor errors in case of server APIs only.There are lot of breaking changes in the API.
Motivation and Context
Closes Change from returning error to HttpError #4
How Has This Been Tested?
faas-netesandfaasdTypes of changes
Checklist:
Commits:
git commit -sfor the Developer Certificate of Origin (DCO)Code:
Docs: