Add check for all required data
This commit is contained in:
@@ -24,6 +24,10 @@ type api struct {}
|
||||
func (api) CallApi(date string, from_time string, to_time string, item_id string, description string) error {
|
||||
if item_id == "break" || item_id == "lunch" || item_id == "pauze" { return nil }
|
||||
|
||||
if date == "" || from_time == "" || to_time == "" || item_id == "" {
|
||||
return fmt.Error("incomplete log entry: %s, %s-%s, %s, %s", date, from_time, to_time, item_id, description)
|
||||
}
|
||||
|
||||
time1, err := time.Parse("15:04", from_time)
|
||||
if err != nil { return fmt.Errorf("error parsing from_time: %s", err) }
|
||||
|
||||
|
||||
+1
-1
@@ -84,7 +84,7 @@ func (self *Process) parseTask(line string, line_number int) error {
|
||||
}
|
||||
|
||||
// Call API for the previous task
|
||||
if date.last_time != "" && date.last_item_id != "" && date.last_description != "" {
|
||||
if date.last_time != "" && date.last_item_id != "" {
|
||||
err = Api.CallApi(data[0], date.last_time, data[1], date.last_item_id, date.last_description)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user