-
-
Notifications
You must be signed in to change notification settings - Fork 19
/
exception.go
45 lines (37 loc) · 1.18 KB
/
exception.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
package sarif
// Exception ...
type Exception struct {
InnerExceptions []*Exception `json:"innerExceptions,omitempty"`
Kind *string `json:"kind,omitempty"`
Message *string `json:"message,omitempty"`
Stack *Stack `json:"stack,omitempty"`
PropertyBag
}
// NewException creates a new Exception and returns a pointer to it
func NewException() *Exception {
return &Exception{}
}
// WithMessage sets the Message
func (exception *Exception) WithMessage(message string) *Exception {
exception.Message = &message
return exception
}
// WithKind sets the Kind
func (exception *Exception) WithKind(kind string) *Exception {
exception.Kind = &kind
return exception
}
// WithStack sets the Stack
func (exception *Exception) WithStack(stack Stack) *Exception {
exception.Stack = &stack
return exception
}
// WithInnerExceptions sets the InnerExceptions
func (exception *Exception) WithInnerExceptions(exceptions []*Exception) *Exception {
exception.InnerExceptions = exceptions
return exception
}
// AddInnerException ...
func (exception *Exception) AddInnerException(toAdd *Exception) {
exception.InnerExceptions = append(exception.InnerExceptions, toAdd)
}