Open JunyiYi opened 5 years ago
Today MM will not check errors in expand or flatten, which is not always correct. For example, to expand/flatten a date.Time type:
expand
flatten
date.Time
func expandStringToDate(input interface{}) (*date.Time, error) { v := input.(string) dateTime, err := date.ParseTime(time.RFC3339, v) if err != nil { return nil, err } result := date.Time{ Time: dateTime, } return &result, nil }
When we call it in the function, MM will generate something like
parameters = xxx.yyy { MyDate: expandStringToDate(dt) };
But ideally, it should generate:
parameters = xxx.yyy {}; if date, err := expandStringToDate(dt); err != nil { return err } else { parameters.MyDate = date; }
Notice that we should propagate all errors up until the top level instead of handling it silently in sub-functions.
errors
We need to introduce some special flags to indicate whether an expand/flatten function returns error or not, and handle that in the caller.
error
Today MM will not check errors in
expand
orflatten
, which is not always correct. For example, to expand/flatten adate.Time
type:Actual Result
When we call it in the function, MM will generate something like
Expected Result
But ideally, it should generate:
Notice that we should propagate all
errors
up until the top level instead of handling it silently in sub-functions.Proposed Solution
We need to introduce some special flags to indicate whether an expand/flatten function returns
error
or not, and handle that in the caller.