Exemple #1
0
// Returns whether run was successful.
func run() bool {
	var sentryClient *raven.Client
	if sentryClient = sentry.GetClient(); sentryClient != nil {
		log.Printf("Using Sentry; ProjectID=%s, URL=%s", sentryClient.ProjectID(), sentryClient.URL())
		// Don't return until we're finished sending to Sentry.
		defer sentryClient.Wait()
		// Ensure main thread panics are caught and reported.
		defer func() {
			if p := recover(); p != nil {
				var err error
				switch rval := p.(type) {
				case error:
					err = rval
				default:
					err = errors.New(fmt.Sprint(rval))
				}
				packet := raven.NewPacket(err.Error(), raven.NewException(err, raven.NewStacktrace(2, 3, nil)))
				log.Printf("[client] Sending panic to Sentry")
				_, ch := sentryClient.Capture(packet, map[string]string{})
				if serr := <-ch; serr != nil {
					log.Printf("SENTRY ERROR: %s", serr)
				}
				panic(p)
			}
		}()
	} else {
		log.Println("Sentry NOT ENABLED.")
	}

	// Error handling in place; now we begin.

	config, err := client.GetConfig()
	if err != nil {
		panic(err)
	}
	if sentryClient != nil {
		sentryClient.SetTagsContext(map[string]string{
			"projectslug": config.Project.Slug,
			"jobstep_id":  config.JobstepID,
		})
	}

	result, err := engine.RunBuildPlan(config)
	log.Printf("[client] Finished: %s", result)
	if err != nil {
		log.Printf("[client] error: %s", err)
		sentry.Error(err, map[string]string{})
	}
	return err == nil && result == engine.RESULT_PASSED
}
Exemple #2
0
// Returns whether run was successful.
func run() bool {
	if sentryClient := sentry.GetClient(); sentryClient != nil {
		// Don't return until we're finished sending to Sentry.
		defer sentryClient.Wait()
		// Ensure main thread panics are caught and reported.
		defer func() {
			if p := recover(); p != nil {
				var err error
				switch rval := p.(type) {
				case error:
					err = rval
				default:
					err = errors.New(fmt.Sprint(rval))
				}
				packet := raven.NewPacket(err.Error(), raven.NewException(err, raven.NewStacktrace(2, 3, nil)))
				log.Printf("[client] Sending panic to Sentry")
				_, ch := sentryClient.Capture(packet, map[string]string{})
				<-ch
				panic(p)
			}
		}()
	}

	// Error handling in place; now we begin.

	config, err := client.GetConfig()
	if err != nil {
		panic(err)
	}

	result, err := engine.RunBuildPlan(config)
	log.Printf("[client] Finished: %s", result)
	if err != nil {
		log.Printf("[client] error: %s", err)
		sentry.Error(err, nil)
	}
	return err == nil && result == engine.RESULT_PASSED
}