// NewNotFoundError returns the custom defined error of type NewNotFoundError.
17020
func NewNotFoundError(entity string, value string) NotFoundError {
	return NotFoundError{entity: entity, key: "id", value: value}
}
1016202
func NewNotFoundErrorWithKey(entity string, key, value string) NotFoundError {
	return NotFoundError{entity: entity, key: key, value: value}
}
864879
func maybeNotFound(err error) (error, bool) {
	if err != nil && gooseerrors.IsNotFound(err) {
		return jujuerrors.NewNotFound(err, ""), true
	}
	return err, false
}
123063
func NewLocatedError(err interface{}, nodes []ast.Node) *Error {
	var origError error
	message := "An unknown error occurred."
	if err, ok := err.(error); ok {
		message = err.Error()
		origError = err
	}
	if err, ok := err.(string); ok {
		message = err
		origError = errors.New(err)
	}
	stack := message
	return NewError(
		message,
		nodes,
		stack,
		nil,
		[]int{},
		origError,
	)
}
47335
func New(errs ...error) error {
	errors := Errors{}
	for _, err := range errs {
		if err != nil {
			errors = append(errors, err)
		}
	}

	if len(errors) == 0 {
		return nil
	}

	if len(errors) == 1 {
		return errors[0]
	}

	return errors
}
1117160
func NewErrorFromPanic(err interface{}) *Error {

	// Parse the filename and line from the originating line of app code.
	// /Users/robfig/code/gocode/src/revel/examples/booking/app/controllers/hotels.go:191 (0x44735)
	stack := string(debug.Stack())
	frame, basePath := findRelevantStackFrame(stack)
	if frame == -1 {
		return nil
	}

	stack = stack[frame:]
	stackElement := stack[:strings.Index(stack, "\n")]
	colonIndex := strings.LastIndex(stackElement, ":")
	filename := stackElement[:colonIndex]
	var line int
	fmt.Sscan(stackElement[colonIndex+1:], &line)

	// Show an error page.
	description := "Unspecified error"
	if err != nil {
		description = fmt.Sprint(err)
	}
	lines, readErr := ReadLines(filename)
	if readErr != nil {
		utilLog.Error("Unable to read file", "file", filename, "error", readErr)
	}
	return &Error{
		Title:       "Runtime Panic",
		Path:        filename[len(basePath):],
		Line:        line,
		Description: description,
		SourceLines: lines,
		Stack:       stack,
	}
}
381783
func NewError(responseCode int, err *sacloud.ResultErrorValue) Error {
	return &apiError{
		responseCode: responseCode,
		origErr:      err,
	}
}
920579
func NewError(options ...func(*Error)) *Error {
	err := &Error{}
	for _, o := range options {
		o(err)
	}

	return err
}
349163
func NewN(ie interface{}, n int, a ...interface{}) error {
	if ie == nil {
		return nil
	}
	switch err := ie.(type) {
	case *Error:
		return err
	case string:
		return newError(err, 2+n, a...)
	case error:
		return newError(err, 2+n, a...)
	default:
		panic("invalid error type")
	}
}
367488
func newError(StatusCode int, Text string) *Error {
	return &Error{
		StatusCode: StatusCode,
		Text:       Text,
	}
}
1283645
func addNewColumnsIfNotFound(db *sql.DB, table string, newColumns []newColumn) (bool, error) {
	for ic := range newColumns {
		var isRowFound bool
		err := db.QueryRow(`SELECT EXISTS( SELECT column_name FROM INFORMATION_SCHEMA.COLUMNS
			WHERE table_name = $1 AND column_name = $2 );`, table, newColumns[ic].Name).Scan(&isRowFound)
		if err != nil {
			return false, err
		}

		if isRowFound {
			return true, nil
		}

		log.Infof("Adding column %s to table %s...", newColumns[ic].Name, table)
		var result sql.Result
		if newColumns[ic].Default != "" {
			result, err = db.Exec(fmt.Sprintf("ALTER TABLE %s ADD COLUMN %s %s DEFAULT %s;",
				table, newColumns[ic].Name, newColumns[ic].Type, newColumns[ic].Default))
		} else {
			result, err = db.Exec(fmt.Sprintf("ALTER TABLE %s ADD COLUMN %s %s;",
				table, newColumns[ic].Name, newColumns[ic].Type))
		}
		if err != nil {
			return false, err
		}

		_, err = result.RowsAffected()
		if err != nil {
			return false, err
		}
	}
	return true, nil
}
544427
func NewError(e error, p Position) Error {
	return &err{error: e, _position: p}
}
533273
func NewNotFound(a Attributes) error {
	name, resource, err := extractResourceName(a)
	if err != nil {
		return apierrors.NewInternalError(err)
	}
	return apierrors.NewNotFound(resource, name)
}
612887
func newError(message string, err error) *Error {
	return &Error{
		Message:      message,
		DetailsError: err,
	}
}
106512
func NewWithError(token string) (*TgBot, error) {
	url := fmt.Sprintf(baseURL, token, "%s")
	furl := fmt.Sprintf(fileURL, token, "%s")
	tgbot := &TgBot{
		Token:                token,
		BaseRequestURL:       url,
		BaseFileRequestURL:   furl,
		MainListener:         nil,
		RelicCfg:             nil,
		BotanIO:              nil,
		TestConditionalFuncs: make([]ConditionCallStructure, 0),
		NoMessageFuncs:       make([]NoMessageCall, 0),
		ChainConditionals:    make([]*ChainStructure, 0),
		BuildingChain:        false,
		DefaultOptions: DefaultOptionsBot{
			CleanInitialUsername:       true,
			AllowWithoutSlashInMention: true,
		},
	}
	user, err := tgbot.GetMe()
	if err != nil {
		return nil, err
		// panic(err)
	} else {
		tgbot.FirstName = user.FirstName
		tgbot.ID = user.ID
		tgbot.Username = *user.Username
	}
	return tgbot, nil
}
252951
func NewForbiddenError(field *FieldPath, value interface{}) *Error {
	return &Error{ErrorTypeForbidden, field.String(), value, ""}
}
359757
func newError(url string, expected []int, got *httpResponse) error {
	return &UnexpectedResponseError{
		URL:      url,
		Expected: expected,
		Actual:   got.Code,
		Data:     got.Data,
	}
}