Change SetExitMessage from taking a string to an error

This commit is contained in:
Alex Dadgar 2015-11-16 14:46:18 -08:00
parent e76a613974
commit ea0edd8c2f
2 changed files with 8 additions and 7 deletions

View File

@ -303,11 +303,10 @@ func (r *TaskRunner) run() {
// Helper function for converting a WaitResult into a TaskTerminated event.
func (r *TaskRunner) waitErrorToEvent(res *cstructs.WaitResult) *structs.TaskEvent {
e := structs.NewTaskEvent(structs.TaskTerminated).SetExitCode(res.ExitCode).SetSignal(res.Signal)
if res.Err != nil {
e.SetExitMessage(res.Err.Error())
}
return e
return structs.NewTaskEvent(structs.TaskTerminated).
SetExitCode(res.ExitCode).
SetSignal(res.Signal).
SetExitMessage(res.Err)
}
// Update is used to update the task of the context

View File

@ -1128,8 +1128,10 @@ func (e *TaskEvent) SetSignal(s int) *TaskEvent {
return e
}
func (e *TaskEvent) SetExitMessage(m string) *TaskEvent {
e.Message = m
func (e *TaskEvent) SetExitMessage(err error) *TaskEvent {
if err != nil {
e.Message = err.Error()
}
return e
}