Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Error handling for expand and flatten functions #36

Open
JunyiYi opened this issue Sep 17, 2019 · 0 comments
Open

[Feature Request] Error handling for expand and flatten functions #36

JunyiYi opened this issue Sep 17, 2019 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@JunyiYi
Copy link
Collaborator

JunyiYi commented Sep 17, 2019

Today MM will not check errors in expand or flatten, which is not always correct. For example, to expand/flatten a date.Time type:

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
}

Actual Result

When we call it in the function, MM will generate something like

parameters = xxx.yyy {
    MyDate: expandStringToDate(dt)
};

Expected Result

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.

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.

@JunyiYi JunyiYi changed the title [Feature Request] Error handling for exand and flatten functions [Feature Request] Error handling for expand and flatten functions Sep 17, 2019
@houkms houkms added the enhancement New feature or request label Oct 9, 2019
@magodo magodo self-assigned this Nov 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants