@@ -41,10 +41,12 @@ type OopsError struct {
41
41
stacktrace * oopsStacktrace
42
42
}
43
43
44
+ // Unwrap returns the underlying error.
44
45
func (o OopsError ) Unwrap () error {
45
46
return o .err
46
47
}
47
48
49
+ // Error returns the error message, without context.
48
50
func (o OopsError ) Error () string {
49
51
if o .err != nil {
50
52
if o .msg == "" {
@@ -57,6 +59,7 @@ func (o OopsError) Error() string {
57
59
return o .msg
58
60
}
59
61
62
+ // Code returns the error cause. Error code is intented to be used by machines.
60
63
func (o OopsError ) Code () string {
61
64
return getDeepestErrorAttribute (
62
65
o ,
@@ -66,6 +69,7 @@ func (o OopsError) Code() string {
66
69
)
67
70
}
68
71
72
+ // Time returns the time when the error occured.
69
73
func (o OopsError ) Time () time.Time {
70
74
return getDeepestErrorAttribute (
71
75
o ,
@@ -75,6 +79,7 @@ func (o OopsError) Time() time.Time {
75
79
)
76
80
}
77
81
82
+ // Duration returns the duration of the error.
78
83
func (o OopsError ) Duration () time.Duration {
79
84
return getDeepestErrorAttribute (
80
85
o ,
@@ -84,6 +89,7 @@ func (o OopsError) Duration() time.Duration {
84
89
)
85
90
}
86
91
92
+ // Domain returns the domain of the error.
87
93
func (o OopsError ) Domain () string {
88
94
return getDeepestErrorAttribute (
89
95
o ,
@@ -93,6 +99,7 @@ func (o OopsError) Domain() string {
93
99
)
94
100
}
95
101
102
+ // Tags returns the tags of the error.
96
103
func (o OopsError ) Tags () []string {
97
104
tags := []string {}
98
105
@@ -103,6 +110,7 @@ func (o OopsError) Tags() []string {
103
110
return lo .Uniq (tags )
104
111
}
105
112
113
+ // Context returns a k/v context of the error.
106
114
func (o OopsError ) Context () map [string ]any {
107
115
return mergeNestedErrorMap (
108
116
o ,
@@ -112,6 +120,7 @@ func (o OopsError) Context() map[string]any {
112
120
)
113
121
}
114
122
123
+ // Trace returns the transaction id, trace id, request id, correlation id, etc.
115
124
func (o OopsError ) Trace () string {
116
125
trace := getDeepestErrorAttribute (
117
126
o ,
@@ -132,6 +141,7 @@ func (o OopsError) Span() string {
132
141
return o .span
133
142
}
134
143
144
+ // Hint returns a hint to the user on how to resolve the error.
135
145
func (o OopsError ) Hint () string {
136
146
return getDeepestErrorAttribute (
137
147
o ,
@@ -141,6 +151,7 @@ func (o OopsError) Hint() string {
141
151
)
142
152
}
143
153
154
+ // Owner identify the owner responsible for resolving the error.
144
155
func (o OopsError ) Owner () string {
145
156
return getDeepestErrorAttribute (
146
157
o ,
@@ -150,6 +161,7 @@ func (o OopsError) Owner() string {
150
161
)
151
162
}
152
163
164
+ // User returns the user id and user data.
153
165
func (o OopsError ) User () (string , map [string ]any ) {
154
166
userID := getDeepestErrorAttribute (
155
167
o ,
@@ -167,6 +179,7 @@ func (o OopsError) User() (string, map[string]any) {
167
179
return userID , userData
168
180
}
169
181
182
+ // Tenant returns the tenant id and tenant data.
170
183
func (o OopsError ) Tenant () (string , map [string ]any ) {
171
184
tenantID := getDeepestErrorAttribute (
172
185
o ,
@@ -184,6 +197,7 @@ func (o OopsError) Tenant() (string, map[string]any) {
184
197
return tenantID , tenantData
185
198
}
186
199
200
+ // Stacktrace returns a pretty printed stacktrace of the error.
187
201
func (o OopsError ) Stacktrace () string {
188
202
blocks := []string {}
189
203
topFrame := ""
@@ -206,6 +220,7 @@ func (o OopsError) Stacktrace() string {
206
220
return "Oops: " + strings .Join (blocks , "\n Thrown: " )
207
221
}
208
222
223
+ // Sources returns the source fragments of the error.
209
224
func (o OopsError ) Sources () string {
210
225
blocks := [][]string {}
211
226
@@ -238,6 +253,7 @@ func (o OopsError) Sources() string {
238
253
)
239
254
}
240
255
256
+ // LogValuer returns a slog.Value for logging.
241
257
func (o OopsError ) LogValuer () slog.Value {
242
258
attrs := []slog.Attr {slog .String ("message" , o .msg )}
243
259
@@ -335,6 +351,7 @@ func (o OopsError) LogValuer() slog.Value {
335
351
return slog .GroupValue (attrs ... )
336
352
}
337
353
354
+ // ToMap returns a map representation of the error.
338
355
func (o OopsError ) ToMap () map [string ]any {
339
356
payload := map [string ]any {}
340
357
@@ -411,6 +428,7 @@ func (o OopsError) ToMap() map[string]any {
411
428
return payload
412
429
}
413
430
431
+ // MarshalJSON implements json.Marshaler.
414
432
func (o OopsError ) MarshalJSON () ([]byte , error ) {
415
433
return json .Marshal (o .ToMap ())
416
434
}
0 commit comments