[Sdk Go] Error handling. Documentation seems faulty

Hi :slight_smile:

Within a workflow i want to react differently given the underlying activity error type but sadly when looking at the documentation on how to do so the proposed method does not exist.
If you take a look at https://docs.temporal.io/docs/go-error-handling you will see the method “OriginalType” but this one does not exist in the returned error nor when casting this one to an applicationError and after searching in the entire sdk code the “OriginalType” only appears in comments.

So i tried different things like applicationError.Unwrap() but this one does not return the underlying error but nil ! Even tho the error message is clearly from my error.

I’m using the 1.3 version of your sdk.
You can see code sample here:

			errAct := workflow.ExecuteActivity(ctxA, some_activity, some_params).Get(ctxA, nil)
			errAct.OriginalType() // does not compile

	var applicationErr *temporal.ApplicationError
	if errors.As(err, &applicationErr) {
		fmt.Println(applicationErr.Unwrap()) //isNil
	}
1 Like

Thanks a lot for pointing out the outdated documentation! We certainly have to fix it.

Serializing and especially deserializing Go errors is not really an option for RPC, especially if cross-language calls (to Java child workflow or activity for example) are possible. So any application-level Go error is converted to ApplicationError. The Go type of the error becomes ApplicationError.Type and the message is the same as of the original error.

If you want to control the ApplicationError.Type or attach additional information to an error use temporal.NewApplicaitonError… variants to create an ApplicationError explicitly.

BTW the best way to report documentation issues is using the “Feedback” button found on the right side of every documentation page.