func (b *Bootstrap) CachedFatalError(err error) (fatalerror.ErrorType, string, bool) {
	if b.bootstrapError == nil {
		return fatalerror.ErrorType(""), "", false
	}
	fatalError, logFunc := b.bootstrapError()
	return fatalError, logFunc(err), true
}
CachedFatalError returns a bootstrap error that occurred during startup and before init
so that it can be reported back to the customer in a later phase
package rapidcore
import (
	"fmt"
	"os"
	"path/filepath"
	"go.amzn.com/lambda/fatalerror"
	"go.amzn.com/lambda/logging"
	"go.amzn.com/lambda/rapid"
	log "github.com/sirupsen/logrus"
)
type LogFormatter func(error) string
type BootstrapError func() (fatalerror.ErrorType, LogFormatter)
type Bootstrap struct {
	orderedLookupPaths []string
	validCmd           []string
	workingDir         string
	cmdCandidates      [][]string
	extraFiles         []*os.File
	bootstrapError     BootstrapError
}
func NewBootstrap(cmdCandidates [][]string, currentWorkingDir string) *Bootstrap {
	var orderedLookupBootstrapPaths []string
	for _, args := range cmdCandidates {
		if len(args) != 0 {
			orderedLookupBootstrapPaths = append(orderedLookupBootstrapPaths, args[0])
		}
	}
	if currentWorkingDir == "" {
		currentWorkingDir = "/"
	}
	return &Bootstrap{
		orderedLookupPaths: orderedLookupBootstrapPaths,
		workingDir:         currentWorkingDir,
		cmdCandidates:      cmdCandidates,
	}
}
func NewBootstrapSingleCmd(cmd []string, currentWorkingDir string) *Bootstrap {
	return &Bootstrap{
		validCmd:   cmd,
		workingDir: currentWorkingDir,
	}
}
func (b *Bootstrap) locateBootstrap() error {
	for i, bootstrapCandidate := range b.orderedLookupPaths {
		if file, err := os.Stat(bootstrapCandidate); !os.IsNotExist(err) && !file.IsDir() {
			b.validCmd = b.cmdCandidates[i]
			return nil
		}
	}
	log.WithField("bootstrapPathsChecked", b.orderedLookupPaths).Warn("Couldn't find valid bootstrap(s)")
	return fmt.Errorf("Couldn't find valid bootstrap(s): %s", b.orderedLookupPaths)
}
func (b *Bootstrap) Cmd() ([]string, error) {
	if len(b.validCmd) > 0 {
		return b.validCmd, nil
	}
	if err := b.locateBootstrap(); err != nil {
		return []string{}, err
	}
	log.Debug("Located runtime bootstrap", b.validCmd[0])
	return b.validCmd, nil
}
func (b *Bootstrap) Env(e rapid.EnvironmentVariables) []string {
	return e.RuntimeExecEnv()
}
func (b *Bootstrap) Cwd() (string, error) {
	if !filepath.IsAbs(b.workingDir) {
		return "", fmt.Errorf("the working directory '%s' is invalid, it needs to be an absolute path", b.workingDir)
	} else if _, err := os.Stat(b.workingDir); os.IsNotExist(err) {
		return "", fmt.Errorf("the working directory doesn't exist: %s", b.workingDir)
	}
	return b.workingDir, nil
}
func (b *Bootstrap) SetExtraFiles(extraFiles []*os.File) {
	b.extraFiles = extraFiles
}
func (b *Bootstrap) ExtraFiles() []*os.File {
	return b.extraFiles
}