From ea0edd8c2fa3dab52b56bdc574dfcc1124294c85 Mon Sep 17 00:00:00 2001 From: Alex Dadgar Date: Mon, 16 Nov 2015 14:46:18 -0800 Subject: [PATCH] Change SetExitMessage from taking a string to an error --- client/task_runner.go | 9 ++++----- nomad/structs/structs.go | 6 ++++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/client/task_runner.go b/client/task_runner.go index 8db5ffb09..984af2767 100644 --- a/client/task_runner.go +++ b/client/task_runner.go @@ -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 diff --git a/nomad/structs/structs.go b/nomad/structs/structs.go index 7c040e9d8..cdfdfa53e 100644 --- a/nomad/structs/structs.go +++ b/nomad/structs/structs.go @@ -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 }