// Copyright 2018 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package errors

import (
	
)

// A Frame contains part of a call stack.
type Frame struct {
	// Make room for three PCs: the one we were asked for, what it called,
	// and possibly a PC for skipPleaseUseCallersFrames. See:
	// https://go.googlesource.com/go/+/032678e0fb/src/runtime/extern.go#169
	frames [3]uintptr
}

// Caller returns a Frame that describes a frame on the caller's stack.
// The argument skip is the number of frames to skip over.
// Caller(0) returns the frame for the caller of Caller.
func ( int) Frame {
	var  Frame
	runtime.Callers(+1, .frames[:])
	return 
}

// Location reports the file, line, and function of a frame.
//
// The returned function may be "" even if file and line are not.
func ( Frame) () (,  string,  int) {
	 := runtime.CallersFrames(.frames[:])
	if ,  := .Next(); ! {
		return "", "", 0
	}
	,  := .Next()
	if ! {
		return "", "", 0
	}
	return .Function, .File, .Line
}

// Format prints the stack as error detail.
// It should be called from an error's Format implementation
// after printing any other error detail.
func ( Frame) ( Printer) {
	if .Detail() {
		, ,  := .Location()
		if  != "" {
			.Printf("%s\n    ", )
		}
		if  != "" {
			.Printf("%s:%d\n", , )
		}
	}
}