diff options
| author | Philipp Tanlak <philipp.tanlak@gmail.com> | 2023-11-20 17:07:28 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-11-20 17:07:28 +0100 |
| commit | 13322edf37510b6d3bb68a853368fd1a0a67a105 (patch) | |
| tree | af325e934f95deeee44cbdd126100dff912f0e5a /modules/jsonprint/jsonprint.go | |
| parent | 47d58e6e0ebc44e7c00dffcc3b892932dc70eb3a (diff) | |
Gracefully handle NaN and Inf values (#21)
Diffstat (limited to 'modules/jsonprint/jsonprint.go')
| -rw-r--r-- | modules/jsonprint/jsonprint.go | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/modules/jsonprint/jsonprint.go b/modules/jsonprint/jsonprint.go index a4be5c9..c40a8b9 100644 --- a/modules/jsonprint/jsonprint.go +++ b/modules/jsonprint/jsonprint.go @@ -41,9 +41,11 @@ func (m *Module) ReceiveResponse(resp *flyscrape.Response) { o := output{ URL: resp.Request.URL, Data: resp.Data, - Error: resp.Error, Timestamp: time.Now(), } + if resp.Error != nil { + o.Error = resp.Error.Error() + } fmt.Print(flyscrape.Prettify(o, " ")) } @@ -57,7 +59,7 @@ func (m *Module) Finalize() { type output struct { URL string `json:"url,omitempty"` Data any `json:"data,omitempty"` - Error error `json:"error,omitempty"` + Error string `json:"error,omitempty"` Timestamp time.Time `json:"timestamp,omitempty"` } |