From cb0c05084f1ae9d31be7dbd1fa435fd6e2ebcab2 Mon Sep 17 00:00:00 2001 From: Jonathan Hurter Date: Wed, 7 Oct 2020 20:40:15 +0200 Subject: [PATCH] Show the error message instead of the error object --- prober/prober.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/prober/prober.go b/prober/prober.go index 6d9ffd45..3f044391 100644 --- a/prober/prober.go +++ b/prober/prober.go @@ -66,11 +66,12 @@ type Result struct { // ProbeResult is the data structure used to retain the data fetched from a single probe type ProbeResult struct { - Name string `json:"name"` - Healthy bool `json:"healthy"` - Comment string `json:"comment"` - Error error `json:"error"` - Duration time.Duration `json:"duration"` + Name string `json:"name"` + Healthy bool `json:"healthy"` + Comment string `json:"comment"` + Error error `json:"-"` + ErrorMessage string `json:"error"` + Duration time.Duration `json:"duration"` } // NewProber is the default constructor of a Prober @@ -152,6 +153,9 @@ func (p *Prober) CheckOneProbe(ctx context.Context, probe Probe, res chan *Probe Error: err, Duration: duration, } + if err != nil { + probeResult.ErrorMessage = err.Error() + } res <- probeResult }