// Create a new report using the given error message and current call stack.
// Supply an integer indicating how many callers to skip (0 is none).
426152
func NewReportWithSkipCallers(msg interface{}, skipCallers int) (r *Report, err error) {
	var cwd, hostname string

	if ApiKey == "" {
		err = errors.New("You must set an API key first")
		return
	}

	if Environment == "" {
		err = errors.New("You must set an environment first")
		return
	}

	cwd, _ = os.Getwd()
	hostname, _ = os.Hostname()

	fullMessage := fullMessage(msg)
	exceptionClass := exceptionClass(fullMessage)

	r = &Report{
		Notifier: &Notifier{
			Name:     "Honeybadger (Go)",
			Url:      "https://github.com/jcoene/honeybadger-go",
			Version:  "1.0",
			Language: "Go",
		},
		Error: &Error{
			Class:     exceptionClass,
			Message:   fullMessage,
			Backtrace: make([]*BacktraceLine, 0),
			Source:    make(map[string]interface{}),
		},
		Request: &Request{
			Params:  make(map[string]interface{}),
			Session: make(map[string]interface{}),
			CgiData: make(map[string]interface{}),
			Context: make(map[string]interface{}),
		},
		Server: &Server{
			ProjectRoot:     make(map[string]interface{}),
			EnvironmentName: Environment,
			Hostname:        hostname,
		},
	}

	callers := make([]uintptr, 10)
	runtime.Callers(0, callers)

	for i, pc := range callers {
		if i < 3 { // skip self-inflicted depth
			continue
		}

		fc := runtime.FuncForPC(pc)
		if fc != nil {
			ms := strings.Split(fc.Name(), "/")
			m := ms[len(ms)-1]
			f, n := fc.FileLine(pc)

			// If we reach our origin depth, use the given function name as error class
			if i == skipCallers+2 {
				r.Error.Class = m
			}

			r.Error.Backtrace = append(r.Error.Backtrace, &BacktraceLine{
				Method: m,
				File:   f,
				Number: fmt.Sprintf("%d", n),
			})
		}
	}

	r.Server.ProjectRoot["path"] = cwd

	return
}
1311858
func New(err ...bool) *Message {
	m := &Message{}
	if len(err) > 0 {
		m.Err = err[0]
	}
	return m
}
1247193
func (mr *MockSecretInterfaceMockRecorder) Create(arg0 interface{}) *gomock.Call {
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Create", reflect.TypeOf((*MockSecretInterface)(nil).Create), arg0)
}
618144
func (f *FailureResponse) AppendErrorMessage(msg string) *FailureResponse {
	return &FailureResponse{
		error:         errors.New(fmt.Sprintf("%s %s", f.Error(), msg)),
		statusCode:    f.statusCode,
		loggerAction:  f.loggerAction,
		emptyResponse: f.emptyResponse,
		errorKey:      f.errorKey,
	}
}
1222361
func NewErrorf(code uint, msg string, args ...interface{}) Error {
	return StandardError{code, PString(fmt.Sprintf(msg, args...))}
}
1230143
func New(code int32, message string, args ...interface{}) Error {
	if len(args) > 0 {
		return &apiError{code, fmt.Sprintf(message, args...)}
	}
	return &apiError{code, message}
}
321899
func New(errType ErrorType, msg string, args ...interface{}) error {
	return &BoulderError{
		Type:   errType,
		Detail: fmt.Sprintf(msg, args...),
	}
}
275678
func NewError(context *Context, message string) *Error {
	return &Error{Context: context, Message: message}
}
445620
func createError(req *Request, r interface{}) *Error {
	if r == nil {
		return nil
	}

	var kiteErr *Error
	switch err := r.(type) {
	case *Error:
		kiteErr = err
	case *dnode.ArgumentError:
		kiteErr = &Error{
			Type:    "argumentError",
			Message: err.Error(),
		}
	default:
		kiteErr = &Error{
			Type:    "genericError",
			Message: fmt.Sprint(r),
		}
	}

	if kiteErr.RequestID == "" && req != nil {
		kiteErr.RequestID = req.ID
	}

	return kiteErr
}
808650
func NewErrorsSkip(skip int, errs ...error) ErrorObject {
	var errcomp ErrorObject
	var errtmp ErrorObject
	for i, size := 0, len(errs); i < size; i++ {
		errtmp = castErrorObject(nil, skip+1, errs[i])
		if errtmp == nil {
			continue
		}

		if errcomp == nil {
			errcomp = errtmp
			continue
		}

		if err := AddParent(errcomp, errtmp); err != nil {
			panic(err)
		}
	}
	return errcomp
}
614714
func NewLogHelper(v ...interface{}) (*LogHelper, error) {
	mask := os.O_APPEND | os.O_RDWR | os.O_CREATE
	mylog := LogHelper{}

	// use stdout & stderr
	if len(v) == 0 {
		mylog.Logger[0] = log.New(os.Stdout, "TRACE - ", FLAGS)
		mylog.Logger[1] = log.New(os.Stderr, "ERROR - ", FLAGS)
		return &mylog, nil
	}
	fileName := v[0].(string)
	// app.log & app.log.error
	mylog.LogFileNames = [2]string{fileName, fileName + ".error"}
	// check dir wether exist and mkdir
	if _, err := os.Stat(path.Dir(mylog.LogFileNames[0])); err != nil {
		os.Mkdir(path.Dir(mylog.LogFileNames[0]), 0777)
	}

	if logFile, err := os.OpenFile(mylog.LogFileNames[0], mask, 0666); err == nil {
		mylog.Logger[0] = log.New(logFile, "TRACE - ", FLAGS)
		mylog.Logger[0].Flags()
	} else {
		return nil, err
	}

	if logFile, err := os.OpenFile(mylog.LogFileNames[1], mask, 0666); err == nil {
		mylog.Logger[1] = log.New(logFile, "ERROR - ", FLAGS)
	} else {
		return nil, err
	}
	return &mylog, nil
}
1033291
func (cl *Call) Error(arguments ...interface{}) {
	cl.scope.log(cl.entry, fmt.Sprintln(arguments...))
	cl.scope.t.Fail()
}
633806
func NewException(err error, stacktrace *Stacktrace) *Exception {
	msg := err.Error()
	ex := &Exception{
		Stacktrace: stacktrace,
		Value:      msg,
		Type:       reflect.TypeOf(err).String(),
	}
	if m := errorMsgPattern.FindStringSubmatch(msg); m != nil {
		ex.Module, ex.Value = m[1], m[2]
	}
	return ex
}
735900
func Throw(text string) error {
	if atomic.LoadInt32(&enableTrace) != 0 {
		return traceError{stack: string(debug.Stack(2)) + "\n", text: text}
	}
	return traceError{text: text}
}
239324
func NewErrorf(code int, format string, args ...interface{}) error {
	return NewError(code, fmt.Sprintf(format, args...))
}
1105031
func Report(ctx context.Context, err error) error {
	e := errors.New(ctx, err, 1)
	return reportWithLevel(ctx, DefaultLevel, e)
}
920579
func NewError(options ...func(*Error)) *Error {
	err := &Error{}
	for _, o := range options {
		o(err)
	}

	return err
}