GoCollections/exceptions/ElementNotFound.go

43 lines
870 B
Go
Raw Normal View History

2021-05-21 09:41:58 +08:00
package exceptions
import (
"io"
"os"
)
type ElementNotFoundException struct {
message string
stackTrace []StackTrace
}
func NewElementNotFoundException(message string, getStackTrace bool) *ElementNotFoundException {
var stackTrace []StackTrace = nil
if getStackTrace {
stackTrace = GetStackTrace()
}
return &ElementNotFoundException{
message: message,
stackTrace: stackTrace,
}
}
func (e ElementNotFoundException) Error() string {
if len(e.message) == 0 {
return "element not found"
} else {
return e.message
}
}
func (e ElementNotFoundException) StackTrace() []StackTrace {
return e.stackTrace
}
func (e ElementNotFoundException) PrintStackTrace() {
e.PrintStackTraceTo(os.Stderr)
}
func (e ElementNotFoundException) PrintStackTraceTo(writer io.Writer) {
PrintStackTrace(writer, e, "exception caused ElementNotFoundException:")
}