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 Oct 23, 2024
1 parent 32bd834 commit c727d3d
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 @@ -483,7 +483,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 @@ -624,7 +627,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 c727d3d

Please sign in to comment.