func (e Error) PrintStackTrace() string {
	for _, v := range e.StackTraces {
		fmt.Println(v)
	}
	return strings.Join(e.StackTraces, "\n")
}
print error stack trace
e.Flag only controls 'Error' type or official error which has been wrapped to 'Error'.
e.Flag only controls stack trace inner an Error type ,rather than some stack trace which has been init by api NewFromStackTrace([]string,string)
package errorx
import (
	"encoding/json"
	"errors"
	"fmt"
	"reflect"
	"runtime"
	"strconv"
	"strings"
	"time"
)
const (
	LcauseBy = 1 << iota
	LdateTime
	Llongfile
)
type Error struct {
	index int
	E           error
	StackTraces []string
	isServiceErr   bool
	serviceErrcode int
	serviceErrmsg  string
	Context map[string]interface{}
	Header  map[string][]string
	ReGenerated bool
	Errors      []error
	Flag        int
	Keyword     string
}
func (e Error) String() string {
	return e.Error()
}
func (e *Error) SetHeader(key string, value string) {
	if e.Header == nil {
		e.Header = make(map[string][]string, 0)
	}
	if e.Header[key] == nil {
		e.Header[key] = make([]string, 0, 10)
	}
	if len(e.Header[key]) == 0 {
		e.Header[key] = append(e.Header[key], value)
	} else {
		e.Header[key][0] = value
	}
}
func (e Error) GetHeader(key string) string {
	if e.Header == nil {
		return ""
	}
	if e.Header[key] == nil || len(e.Header[key]) == 0 {
		return ""
	}
	return e.Header[key][0]
}
func Empty() Error {
	return Error{
		index:       0,
		E:           nil,
		StackTraces: make([]string, 0, 30),
		Context:     make(map[string]interface{}, 0),
		ReGenerated: false,
		Errors:      make([]error, 0, 30),
		Flag:        Llongfile | LcauseBy | LdateTime,
	}
}
func (e Error) Error() string {
	var header = ""
	if len(e.Header) != 0 {
		buf, _ := json.MarshalIndent(e.Header, "  ", "  ")
		header += fmt.Sprintf("header:\n%s\n", buf)
	}
	rs := fmt.Sprintf("%s%s\n", header, e.StackTraceValue())
	if len(e.Context) != 0 {
		buf, _ := json.MarshalIndent(e.Context, "  ", "  ")
		rs += fmt.Sprintf("context:\n%s\n", buf)
	}
	return rs
}
func (e Error) BasicError() string {
	if e.E != nil {
		return e.E.Error()
	}
	return ""
}
func (e Error) StackTrace() string {
	rs := "\n"
	for _, v := range e.StackTraces {
		rs = rs + v + "\n"
	}
	return rs
}
func NewWithHeader(e error, header map[string]interface{}) error {
	if e == nil {
		return nil
	}
	er := New(e).(Error)
	for k, v := range header {
		er.SetHeader(k, ToString(v))
	}
	return er
}
func NewWithAttach(e error, msg interface{}) error {
	if e == nil {
		return nil
	}
	msg = ToString(msg)
	er := New(e).(Error)
	er.SetHeader("attach", msg.(string))
	return er
}
func New(e error) error {
	if e == nil {
		return nil
	}
	switch v := e.(type) {
	case Error:
		_, file, line, _ := runtime.Caller(1)
		trace := PrintStackFormat(v.Flag, file, line, v.BasicError())
		v.StackTraces = append(v.StackTraces, trace)
		return v
	case error:
		errorX := Empty()
		errorX.E = e
		errorX.Errors = append(errorX.Errors, e)
		_, file, line, _ := runtime.Caller(1)
		trace := PrintStackFormat(Llongfile|LcauseBy|LdateTime, file, line, v.Error())
		errorX.StackTraces = append(errorX.StackTraces, trace)
		return errorX
	}
	return New(errors.New("invalid error type,error type should be official or errorx.Error"))
}