// Send the report and return an error if present
548237
func (r *Report) Send() (err error) {
	var req *http.Request
	var resp *http.Response
	var payload []byte

	if payload, err = json.MarshalIndent(r, "", "  "); err != nil {
		return
	}

	if req, err = http.NewRequest("POST", "https://api.honeybadger.io/v1/notices", bytes.NewBuffer(payload)); err != nil {
		return
	}

	req.Header.Add("Content-Type", "application/json")
	req.Header.Add("Accept", "application/json")
	req.Header.Add("X-API-Key", ApiKey)

	if resp, err = Client.Do(req); err != nil {
		return
	}
	defer resp.Body.Close()

	if resp.StatusCode < 201 {
		err = errors.New(fmt.Sprintf("unable to send: error %d", resp.StatusCode))
	}
	return
}
1132364
func (c *Client) Send(msg *Message) error {
	buf, err := json.Marshal(msg)
	if err != nil {
		return err
	}
	resp, err := c.HTTPClient.Post(c.url, "application/json", bytes.NewReader(buf))
	if err != nil {
		return err
	}
	defer resp.Body.Close()

	// Discard response body to reuse connection
	io.Copy(ioutil.Discard, resp.Body)

	if resp.StatusCode != 200 {
		return fmt.Errorf("unexpected status code: %d", resp.StatusCode)
	}
	return nil
}
586052
func (s *ReportStatus) Error() error {
	if s.UnpackStatus != ok {
		return fmt.Errorf("unpack error: %s", s.UnpackStatus)
	}

	for _, s := range s.CommandStatuses {
		if err := s.Error(); err != nil {
			return err
		}
	}

	return nil
}
759554
func ReportWithLevel(ctx context.Context, level string, err error) error {
	e := errors.New(ctx, err, 1)
	return reportWithLevel(ctx, level, e)
}
187822
func sendAndExitIfError(err error, response *plugins.Response) {
	if err != nil {
		response.Errors = append(response.Errors, err.Error())
		sendAndExit(response)
	}
}
3570
func SendError(w http.ResponseWriter, data interface{}, rCode int) {
	rw := responseWriter{
		ResponseWriter: w,
		code:           rCode,
	}

	err := json.NewEncoder(rw).Encode(errOutput{data, rCode})
	if err != nil {
		/*
			In case of encoding error, send "internal server error" after
			logging the actual error.
		*/
		LOGHANDLER.Error(err)
		R500(w, ErrInternalServer)
	}
}
1219193
func (h *LogReporter) ReportWithLevel(ctx context.Context, level string, err error) error {
	var file, line string
	var stack errors.StackTrace

	if errWithStack, ok := err.(stackTracer); ok {
		stack = errWithStack.StackTrace()
	}
	if stack != nil && len(stack) > 0 {
		file = fmt.Sprintf("%s", stack[0])
		line = fmt.Sprintf("%d", stack[0])
	} else {
		file = "unknown"
		line = "0"
	}

	if level == "debug" {
		logger.Debug(ctx, "", "debug", fmt.Sprintf(`"%v"`, err), "line", line, "file", file)
	} else if level == "info" {
		logger.Info(ctx, "", "info", fmt.Sprintf(`"%v"`, err), "line", line, "file", file)
	} else {
		logger.Error(ctx, "", level, fmt.Sprintf(`"%v"`, err), "line", line, "file", file)
	}
	return nil
}
489174
func (fc FunctionReporter) Report(isSlaveType, shouldQueryServiceBeRunning bool) (time.Duration, error) {
	return fc(isSlaveType, shouldQueryServiceBeRunning)
}
920793
func (res *Response) Send(strings ...string) error {
	if err := res.Robot.Adapter.Send(res, strings...); err != nil {
		Logger.Error(err)
		return err
	}
	return nil
}
3595
func (r *Reporter) Report(ctx context.Context) {
	logger := r.Logger.With(
		zap.String("service", "telemetry"),
		influxlogger.DurationLiteral("interval", r.Interval),
	)

	logger.Info("Starting")
	if err := r.Pusher.Push(ctx); err != nil {
		logger.Debug("failure reporting telemetry metrics", zap.Error(err))
	}

	ticker := time.NewTicker(r.Interval)
	defer ticker.Stop()
	for {
		select {
		case <-ticker.C:
			logger.Debug("Reporting")
			if err := r.Pusher.Push(ctx); err != nil {
				logger.Debug("failure reporting telemetry metrics", zap.Error(err))
			}
		case <-ctx.Done():
			logger.Info("Stopping")
			return
		}
	}
}
1010525
func (s *StatusReport) Report() *Report {
	rep := &Report{
		TokendVersion:  s.Version,
		ServiceVersion: s.ServiceVersion,
		StartedTS:      s.Started.Unix(),
		TotalDuration:  s.Finished.Sub(s.Started).Nanoseconds() / 1000,
		RPCDuration:    s.MintTokenDuration.Nanoseconds() / 1000,
		UpdateOutcome:  string(s.UpdateOutcome),
		UpdateReason:   string(s.UpdateReason),
	}
	if s.FailureError != nil {
		rep.FailureError = s.FailureError.Error()
	}
	if s.LastToken != nil {
		rep.TokenLastUpdateTS = s.LastToken.LastUpdate
		rep.TokenNextUpdateTS = s.LastToken.NextUpdate
		rep.TokenExpiryTS = s.LastToken.Expiry
	}
	return rep
}
916140
func Report(cl *trace.Client, samples *ssf.Samples) error {
	return ReportBatch(cl, samples.Batch)
}
704752
func (gosec *Analyzer) Report() ([]*Issue, *Metrics, map[string][]Error) {
	return gosec.issues, gosec.stats, gosec.errors
}
663479
func (s *Service) report(conn *websocket.Conn) error {
	if err := s.reportLatency(conn); err != nil {
		return err
	}
	if err := s.reportBlock(conn, nil); err != nil {
		return err
	}
	if err := s.reportPending(conn); err != nil {
		return err
	}
	if err := s.reportStats(conn); err != nil {
		return err
	}
	return nil
}
456245
func (s *server) send(value interface{}) (interface{}, error) {
	if !s.Running() {
		return nil, StopError
	}

	event := &ev{target: value, c: make(chan error, 1)}
	select {
	case s.c <- event:
	case <-s.stopped:
		return nil, StopError
	}
	select {
	case <-s.stopped:
		return nil, StopError
	case err := <-event.c:
		return event.returnValue, err
	}
}
1368435
func (c *Conn) sendAlert(err Alert) error {
	c.handshakeMutex.Lock()
	defer c.handshakeMutex.Unlock()

	var level int
	switch err {
	case AlertNoRenegotiation, AlertCloseNotify:
		level = AlertLevelWarning
	default:
		level = AlertLevelError
	}

	buf := []byte{byte(err), byte(level)}
	c.out.WriteRecord(&TLSPlaintext{
		contentType: RecordTypeAlert,
		fragment:    buf,
	})

	// close_notify and end_of_early_data are not actually errors
	if level == AlertLevelWarning {
		return &net.OpError{Op: "local error", Err: err}
	}

	return c.Close()
}
1260062
func (c *Client) Send(t int, data []byte) (err error) {
	return c.Conn.WriteMessage(t, data)
}