Returning partial results from activity on error

The Get() call on a future either returns a non-nil error or assigns result value to the provided pointer. Can it do both?

I have a use-case where I want to return partial results from an activity even when there is an error in the activity.

I would include the partial results into the ApplicationError:

func MyActivity(...) error {
	...
	if err != nil {
	   return temporal.NewApplicationErrorWithCause("Activity failure", "partial", err, &PartialDetails{ ... })
	}
	...
}

And then workflow should be able to get them:

err := workflow.ExecuteActivity(ctx, MyActivity, ...).Get(ctx, nil)
if err != nil {
	var applicationErr *ApplicationError
	if errors.As(err, &applicationError) {
		// handle activity errors (created via NewApplicationError() API)
		var details PartialDetails
		applicationErr.Details(&details) // extract strong typed details
                ...
        }
        ...
}

Thank you. That works. However, it would be easier if it is possible to achieve the same in the workflow without piggybacking the result on the error.

It is not possible as Temporal provides SDKs in many languages and most of them don’t support returning failure and a result at the same time.