faas-cli icon indicating copy to clipboard operation
faas-cli copied to clipboard

Provide better error handling for SDK error

Open viveksyngh opened this issue 4 years ago • 7 comments

Provide a better way to check for the errors returned by SDK function.

Expected Behaviour

Create custom error package with types/methods for different errors returned by SDK, which will allows users to check for specific errors as below

errors.IsSuchandsuch(err)

Current Behaviour

Right now these checks can be performed using string matching with error messages

Possible Solution

Steps to Reproduce (for bugs)

Context

Your Environment

  • FaaS-CLI version ( Full output from: faas-cli version ):

  • Docker version ( Full output from: docker version ):

  • Are you using Docker Swarm (FaaS-swarm ) or Kubernetes (FaaS-netes)?

  • Operating System and version (e.g. Linux, Windows, MacOS):

  • Link to your project or a code example to reproduce issue:

viveksyngh avatar Apr 11 '20 17:04 viveksyngh

Derek assign: me

viveksyngh avatar Apr 11 '20 17:04 viveksyngh

@viveksyngh do you have an update on this?

alexellis avatar Jul 07 '20 08:07 alexellis

@viveksyngh just checking in again now, as it's been quite a few months since this came up on the radar for you to work on. I also asked several months ago what your update was.

Please can you take time to answer and keep us in the loop? Do you want someone else to take this?

alexellis avatar Oct 09 '20 10:10 alexellis

I will un-assign it and let it be open for someone else to take it. I will try to complete my current tasks and then comeback to this one.

viveksyngh avatar Oct 11 '20 15:10 viveksyngh

Ok, would you mind detailing a solution so that someone else could pick it up later?

alexellis avatar Oct 11 '20 15:10 alexellis

@alexellis I would like to work on this

We need to discuss how we want to add different error types like auth error, build error, connection error etc. And can add different functions like:

type Error struct {
	Msg error `json:"err_msg"`
}

func (e Error) AuthenticationError() error {
	return fmt.Errorf("authentication error: %s", e.Msg)
}

for each.

Please give your thoughts.

NikhilSharmaWe avatar May 28 '23 18:05 NikhilSharmaWe

Hi @NikhilSharmaWe for the time being we've worked around this and created a separate Go SDK:

https://github.com/openfaas/go-sdk

There are some additional methods we could add - perhaps check out the Swagger and suggest on this issue what's missing or could be added?

https://github.com/openfaas/faas/blob/master/api-docs/swagger.yml

The Swagger also wasn't updated for namespaces support in OpenFaaS for Enterprises, so that could be something you could add to the Swagger in a separate PR - including the list namespaces endpoint.

Alex

alexellis avatar May 31 '23 13:05 alexellis