// NewAssembleError returns a new error which indicates there was a problem
// running assemble script
493704
func NewAssembleError(name, output string, err error) error {
	return Error{
		Message:    fmt.Sprintf("assemble for %s failed:\n%s", name, output),
		Details:    err,
		ErrorCode:  AssembleError,
		Suggestion: "check the assemble script output for errors",
	}
}
744135
func NewBatchedWriterAssembly(config BatchedWriterConfig, modulator core.Modulator, tryFallback func(*core.Message), logger logrus.FieldLogger) *BatchedWriterAssembly {
	return &BatchedWriterAssembly{
		Batch:    core.NewMessageBatch(config.BatchMaxCount),
		assembly: core.NewWriterAssembly(nil, tryFallback, modulator),
		config:   config,
		logger:   logger,
	}
}
1268373
func (gosec *Analyzer) AppendError(file string, err error) {
	// Do not report the error for empty packages (e.g. files excluded from build with a tag)
	r := regexp.MustCompile(`no buildable Go source files in`)
	if r.MatchString(err.Error()) {
		return
	}
	errors := []Error{}
	if ferrs, ok := gosec.errors[file]; ok {
		errors = ferrs
	}
	ferr := NewError(0, 0, err.Error())
	errors = append(errors, *ferr)
	gosec.errors[file] = errors
}
92940
func NewCLIError(msg string, args ...interface{}) error {
	return CommandLineError{fmt.Errorf(msg, args...)}
}
367488
func newError(StatusCode int, Text string) *Error {
	return &Error{
		StatusCode: StatusCode,
		Text:       Text,
	}
}
1161585
func newCompileError(paths *model.RevelContainer, output []byte) *utils.Error {
	errorMatch := regexp.MustCompile(`(?m)^([^:#]+):(\d+):(\d+:)? (.*)$`).
		FindSubmatch(output)
	if errorMatch == nil {
		errorMatch = regexp.MustCompile(`(?m)^(.*?):(\d+):\s(.*?)$`).FindSubmatch(output)

		if errorMatch == nil {
			utils.Logger.Error("Failed to parse build errors", "error", string(output))
			return &utils.Error{
				SourceType:  "Go code",
				Title:       "Go Compilation Error",
				Description: "See console for build error.",
			}
		}

		errorMatch = append(errorMatch, errorMatch[3])

		utils.Logger.Error("Build errors", "errors", string(output))
	}

	findInPaths := func(relFilename string) string {
		// Extract the paths from the gopaths, and search for file there first
		gopaths := filepath.SplitList(build.Default.GOPATH)
		for _, gp := range gopaths {
			newPath := filepath.Join(gp,"src", paths.ImportPath, relFilename)
			println(newPath)
			if utils.Exists(newPath) {
				return newPath
			}
		}
		newPath, _ := filepath.Abs(relFilename)
		utils.Logger.Warn("Could not find in GO path", "file", relFilename)
		return newPath
	}


	// Read the source for the offending file.
	var (
		relFilename  = string(errorMatch[1]) // e.g. "src/revel/sample/app/controllers/app.go"
		absFilename  = findInPaths(relFilename)
		line, _      = strconv.Atoi(string(errorMatch[2]))
		description  = string(errorMatch[4])
		compileError = &utils.Error{
			SourceType:  "Go code",
			Title:       "Go Compilation Error",
			Path:        relFilename,
			Description: description,
			Line:        line,
		}
	)

	errorLink := paths.Config.StringDefault("error.link", "")

	if errorLink != "" {
		compileError.SetLink(errorLink)
	}

	fileStr, err := utils.ReadLines(absFilename)
	if err != nil {
		compileError.MetaError = absFilename + ": " + err.Error()
		utils.Logger.Info("Unable to readlines "+compileError.MetaError, "error", err)
		return compileError
	}

	compileError.SourceLines = fileStr
	return compileError
}
108850
func NewFactory(errtext string) ErrorFactory {
	callinfo, _ := RuntimeCaller(1)
	return NewNamedFactory(callinfo.PackageName()+"->"+errtext, errtext)
}
524904
func (f vboxRunner) RunCombinedError(args ...string) (string, error) {
	wout, werr, err := f.Run(args...)
	if err != nil {
		if werr != "" {
			return wout, fmt.Errorf("%s: %s", err, werr)
		}
		return wout, err
	}

	return wout, nil
}
1086325
func NewWriterAssembly(writer io.Writer, flush func(*Message), modulator Modulator) WriterAssembly {
	return WriterAssembly{
		writer:      writer,
		modulator:   modulator,
		flush:       flush,
		writerGuard: new(sync.Mutex),
	}
}
1317562
func NewError(errorType ErrorType, err error) Error {
	return Error{errorType: errorType, source: err}
}
1331618
func NewErrorExitError(message string, err error) error {
	if wordRegex.MatchString(message[len(message)-1:]) {
		message += "."
	}
	return cli.NewExitError(message+"\n"+err.Error(), -1)
}
785872
func NewError(err error) *Error {
	e := &Error{}
	if err != nil {
		e.Store(err)
	}
	return e
}
1326255
func MakeError(s string) UnionSassValue {
	cs := C.CString(s)
	defer C.free(unsafe.Pointer(cs))
	return C.sass_make_error(cs)
}
652089
func NewProcessingError(row int, cause error) error {
	return fmt.Errorf("Error loading row %d: %s", row, cause.Error())
}
542998
func NewAPIError(response *http.Response) APIError {
	// TODO: handle this error
	body, _ := ioutil.ReadAll(response.Body)

	return NewAPIErrorFromBody(response, body)
}
863327
func NewError(code int, message string) ServiceError {
	return ServiceError{Code: code, Message: message}
}
75018
func NewError(code int, err error) error {
	return &Error{
		code:  code,
		error: err,
	}
}