mirror of
https://github.com/tursom/GoCollections.git
synced 2025-03-14 01:10:18 +08:00
43 lines
870 B
Go
43 lines
870 B
Go
|
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:")
|
||
|
}
|