コード例 #1
0
ファイル: errors.go プロジェクト: JessonChan/go-start
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})
	}
}
コード例 #2
0
ファイル: errors.go プロジェクト: JessonChan/go-start
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
}
コード例 #3
0
ファイル: functions.go プロジェクト: sedzinreri/go-start
// 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...)
}