Error handling using go-sdk

Hello! I hope everyone is well and safe!

I am still learning, and I couldn’t find a solution on the docs, so sorry about those simples questions.

My doubt is: how to handle errors coming from, for example, QueryWorkflow method, from golang sdk client?

I went through the code and checked some comments, and I got this

// The errors it can return:
//  - BadRequestError
//  - InternalServiceError
//  - EntityNotExistError
//  - QueryFailError

So far so good, but I couldn’t find any type defining those errors.

In short terms: I want to check if a workflow already exists, and if not, I want to create a workflow with and standardized WorkflowID (eg: test_vinicius).

How could I do that? Or how could I check the error returned from QueryWorkflow has type EntityNotExistError?

Unfortunately this comment is outdated. I created an issue to fix it (thanks for reporting). You can check actual errors that server may return here.

Btw, QueryWorkflow is to send a query to workflow handler defined by workflow.SetQueryHandler. If you want just to check if workflow exists or not you can use workflow.GetWorkflow which will return serviceerror.NotFound in case if workflow doesn’t exist.

1 Like

Thanks a million @alex !