if f.Metadata != nil {
switch f.Metadata["type"] {
opts := protojson.UnmarshalOptions{DiscardUnknown: true}
if err := opts.Unmarshal(f.Details, apiFailure); err != nil {
return nil, err
}
// Restore these fields as they are not included in the marshalled failure.
apiFailure.StackTrace = f.StackTrace
case "nexus.OperationError":
// Special case for OperationError that adapts from Nexus semantics to Temporal semantics.