Skip to content

Commit

Permalink
Handle failure in parsing employee_hire_date field
Browse files Browse the repository at this point in the history
  • Loading branch information
kang8 committed Jul 18, 2024
1 parent 24c8257 commit 9840450
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions internal/services/users/user_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,10 @@ func userResourceCreate(ctx context.Context, d *pluginsdk.ResourceData, meta int
}

if v, ok := d.GetOk("employee_hire_date"); ok {
employeeHireDate, _ := time.Parse(time.RFC3339, v.(string))
employeeHireDate, err := time.Parse(time.RFC3339, v.(string))
if err != nil {
tf.ErrorDiagF(err, "Unable to parse the provided employee_hire_date %q: %+v", v, err)
}
properties.EmployeeHireDate = &employeeHireDate
}

Expand Down Expand Up @@ -588,7 +591,10 @@ func userResourceUpdate(ctx context.Context, d *pluginsdk.ResourceData, meta int
}

if d.HasChange("employee_hire_date") {
employeeHireDate, _ := time.Parse(time.RFC3339, d.Get("employee_hire_date").(string))
employeeHireDate, err := time.Parse(time.RFC3339, d.Get("employee_hire_date").(string))
if err != nil {
tf.ErrorDiagF(err, "Unable to parse the provided employee_hire_date %q: %+v", d.Get("employee_hire_date"), err)
}
properties.EmployeeHireDate = &employeeHireDate
}

Expand Down

0 comments on commit 9840450

Please sign in to comment.