You cannot pass application specific failures across process boundaries. Any non temporal error is converted to an ApplicationError. You can attach any application specific information to that error as details.
Thanks for the quick response, sorry for not explaining clear enough (Sorry for confusion of naming my struct as Error, and include fields like Cause and Detail similar to the one in ApplicationError). After execution of the activity, I did try to use a unwrap function to unwrap the application error and get back what is within the detail
// UnwrapError extracts the original error from a typeless error. In particular, Temporal wraps the
// errors returned by activities and workflows in its own objects that we want to get back.
func UnwrapError(err error) *Error {
if err == nil {
return nil
}
// Check if the error is an Error type error.
var xErr *Error
if errors.As(err, &xErr) {
return xErr
}
// Check if we received a generic application error.
var appErr *temporal.ApplicationError
if errors.As(err, &appErr) {
// Try to get the error if it is embedded in the details field.
if appErr.Details(&xErr) == nil {
return xErr
}
}
// Return the unknown error as it is.
return &Error{
Cause: err.Error(),
}
}
but it didn’t work and didn’t get back the Error struct detail to me if in my Error struct, the Detail field is an error type. Unless, I change the Detail field to be string, everything works fine. Any ideas for what’s happening behind? Is it true that I cannot put a error type field into the Detail of applicationError
You cannot put interface types into structures passed across the wire. The serialized JSON doesn’t contain type information and doesn’t know to which exact type to deserialize.