From a9dacee062eb3a35cb0416caf837b088650e9764 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paulo=20Sima=CC=83o?= Date: Sat, 16 Oct 2021 08:50:00 -0300 Subject: [PATCH] Added error --- api/replay/cli.go | 16 ++++++++++++++++ types/lib.go | 9 +++++++++ 2 files changed, 25 insertions(+) diff --git a/api/replay/cli.go b/api/replay/cli.go index e80f1a0..feb4438 100644 --- a/api/replay/cli.go +++ b/api/replay/cli.go @@ -4,6 +4,7 @@ import ( "encoding/json" "fmt" "os" + "runtime" "time" "go.digitalcircle.com.br/open/replaycli-go/api" @@ -139,6 +140,21 @@ func (c *Cli) ServiceStopAll() error { return c.HttpCli().JsonGet("/api/v1/service/op/stopall", nil) } +func (c *Cli) Err(err string, desc string) error { + bs := make([]byte, 4096) + n := runtime.Stack(bs, false) + cd, _ := c.QueueGetMyData() + e := &types.Error{ + Feature: c.ReplayEnvAlias(), + Err: err, + When: time.Time{}, + Stack: string(bs[:n]), + InputData: string(cd), + Details: desc, + } + return c.HttpCli().JsonPost("/api/v1/err", e, nil) +} + type SQLReturn struct { Data []map[string]interface{} `json:"data"` Err string `json:"err"` diff --git a/types/lib.go b/types/lib.go index 6af5596..c6765ca 100644 --- a/types/lib.go +++ b/types/lib.go @@ -426,6 +426,15 @@ type Series struct { Year int `json:"year"` } +type Error struct { + Feature string `json:"feature,omitempty"` + When time.Time `json:"when"` + Err string `json:"err,omitempty"` + Stack string `json:"stack,omitempty"` + InputData string `json:"input_data,omitempty"` + Details string `json:"details,omitempty"` +} + func (s *Series) SetTime(t time.Time) { s.When = t s.Day = t.Day()