Added error

nats
Paulo Simão 2021-10-16 08:50:00 -03:00
parent 6eda8f5249
commit a9dacee062
2 changed files with 25 additions and 0 deletions

View File

@ -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"`

View File

@ -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()