-
Notifications
You must be signed in to change notification settings - Fork 14
/
gen_FixedReversibleDbException.go
105 lines (86 loc) · 2.32 KB
/
gen_FixedReversibleDbException.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// Code generated by gotemplate. DO NOT EDIT.
package exception
import (
"bytes"
"encoding/json"
"reflect"
"strconv"
"github.com/eosspark/eos-go/log"
)
// template type Exception(PARENT,CODE,WHAT)
var FixedReversibleDbExceptionName = reflect.TypeOf(FixedReversibleDbException{}).Name()
type FixedReversibleDbException struct {
_MiscException
Elog log.Messages
}
func NewFixedReversibleDbException(parent _MiscException, message log.Message) *FixedReversibleDbException {
return &FixedReversibleDbException{parent, log.Messages{message}}
}
func (e FixedReversibleDbException) Code() int64 {
return 3100004
}
func (e FixedReversibleDbException) Name() string {
return FixedReversibleDbExceptionName
}
func (e FixedReversibleDbException) What() string {
return "Corrupted reversible block database was fixed"
}
func (e *FixedReversibleDbException) AppendLog(l log.Message) {
e.Elog = append(e.Elog, l)
}
func (e FixedReversibleDbException) GetLog() log.Messages {
return e.Elog
}
func (e FixedReversibleDbException) TopMessage() string {
for _, l := range e.Elog {
if msg := l.GetMessage(); len(msg) > 0 {
return msg
}
}
return e.String()
}
func (e FixedReversibleDbException) DetailMessage() string {
var buffer bytes.Buffer
buffer.WriteString(strconv.Itoa(int(e.Code())))
buffer.WriteByte(' ')
buffer.WriteString(e.Name())
buffer.Write([]byte{':', ' '})
buffer.WriteString(e.What())
buffer.WriteByte('\n')
for _, l := range e.Elog {
buffer.WriteByte('[')
buffer.WriteString(l.GetMessage())
buffer.Write([]byte{']', ' '})
buffer.WriteString(l.GetContext().String())
buffer.WriteByte('\n')
}
return buffer.String()
}
func (e FixedReversibleDbException) String() string {
return e.DetailMessage()
}
func (e FixedReversibleDbException) MarshalJSON() ([]byte, error) {
type Exception struct {
Code int64 `json:"code"`
Name string `json:"name"`
What string `json:"what"`
}
except := Exception{
Code: 3100004,
Name: FixedReversibleDbExceptionName,
What: "Corrupted reversible block database was fixed",
}
return json.Marshal(except)
}
func (e FixedReversibleDbException) Callback(f interface{}) bool {
switch callback := f.(type) {
case func(*FixedReversibleDbException):
callback(&e)
return true
case func(FixedReversibleDbException):
callback(e)
return true
default:
return false
}
}