Example #1
0
func ExitWithError(err error) {
	if Debugging || errutil.IsFatalError(err) {
		Panic(err, err.Error())
	} else {
		if inner := errutil.GetInnerError(err); inner != nil {
			Error(inner.Error())
		}
		Exit(err.Error())
	}
}
Example #2
0
func upload(c *uploadContext, unfiltered []*lfs.WrappedPointer) {
	if c.DryRun {
		for _, p := range unfiltered {
			if c.HasUploaded(p.Oid) {
				continue
			}

			Print("push %s => %s", p.Oid, p.Name)
			c.SetUploaded(p.Oid)
		}

		return
	}

	q, pointers := c.prepareUpload(unfiltered)
	for _, p := range pointers {
		u, err := lfs.NewUploadable(p.Oid, p.Name)
		if err != nil {
			if errutil.IsCleanPointerError(err) {
				Exit(uploadMissingErr, p.Oid, p.Name, errutil.ErrorGetContext(err, "pointer").(*lfs.Pointer).Oid)
			} else {
				ExitWithError(err)
			}
		}

		q.Add(u)
		c.SetUploaded(p.Oid)
	}

	q.Wait()

	for _, err := range q.Errors() {
		if Debugging || errutil.IsFatalError(err) {
			LoggedError(err, err.Error())
		} else {
			if inner := errutil.GetInnerError(err); inner != nil {
				Error(inner.Error())
			}
			Error(err.Error())
		}
	}

	if len(q.Errors()) > 0 {
		os.Exit(2)
	}
}