Exemplo n.º 1
0
func PanicIfErrIndexOutOfBounds(what string, index int, length int) {
	if index < 0 || index >= length {
		if Config.FormatWithCallStack {
			what += debug.CallStackInfo(2)
		}
		panic(&ErrIndexOutOfBounds{what, index, length})
	}
}
Exemplo n.º 2
0
func IfErrIndexOutOfBounds(what string, index int, length int) *ErrIndexOutOfBounds {
	if index < 0 || index >= length {
		if Config.FormatWithCallStack {
			what += debug.CallStackInfo(2)
		}
		return &ErrIndexOutOfBounds{what, index, length}
	}
	return nil
}
Exemplo n.º 3
0
// FormatSkipStackFrames formats an error with call stack information if FormatWithCallStack is true.
// It skips skip stack frames.
func FormatSkipStackFrames(skip int, format string, args ...interface{}) error {
	if Config.FormatWithCallStack {
		format += "\n" + debug.CallStackInfo(skip+1)
	}
	return fmt.Errorf(format, args...)
}