當前位置: 首頁>>代碼示例>>Golang>>正文


Golang errors.Error類代碼示例

本文整理匯總了Golang中cf/errors.Error的典型用法代碼示例。如果您正苦於以下問題:Golang Error類的具體用法?Golang Error怎麽用?Golang Error使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Error類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: updateApp

func (cmd *Push) updateApp(app models.Application, appParams models.AppParams) (updatedApp models.Application) {
	cmd.ui.Say("Updating app %s in org %s / space %s as %s...",
		terminal.EntityNameColor(app.Name),
		terminal.EntityNameColor(cmd.config.OrganizationFields().Name),
		terminal.EntityNameColor(cmd.config.SpaceFields().Name),
		terminal.EntityNameColor(cmd.config.Username()),
	)

	if appParams.EnvironmentVars != nil {
		for key, val := range app.EnvironmentVars {
			if _, ok := (*appParams.EnvironmentVars)[key]; !ok {
				(*appParams.EnvironmentVars)[key] = val
			}
		}
	}

	var apiErr errors.Error
	updatedApp, apiErr = cmd.appRepo.Update(app.Guid, appParams)
	if apiErr != nil {
		cmd.ui.Failed(apiErr.Error())
		return
	}

	cmd.ui.Ok()
	cmd.ui.Say("")

	return
}
開發者ID:knolleary,項目名稱:cli,代碼行數:28,代碼來源:push.go

示例2: Run

func (cmd MarketplaceServices) Run(c *cli.Context) {
	var (
		serviceOfferings models.ServiceOfferings
		apiErr           errors.Error
	)

	if cmd.config.HasSpace() {
		cmd.ui.Say("Getting services from marketplace in org %s / space %s as %s...",
			terminal.EntityNameColor(cmd.config.OrganizationFields().Name),
			terminal.EntityNameColor(cmd.config.SpaceFields().Name),
			terminal.EntityNameColor(cmd.config.Username()),
		)
		serviceOfferings, apiErr = cmd.serviceRepo.GetServiceOfferingsForSpace(cmd.config.SpaceFields().Guid)
	} else if !cmd.config.IsLoggedIn() {
		cmd.ui.Say("Getting all services from marketplace...")
		serviceOfferings, apiErr = cmd.serviceRepo.GetAllServiceOfferings()
	} else {
		cmd.ui.Failed("Cannot list marketplace services without a targetted space")
	}

	if apiErr != nil {
		cmd.ui.Failed(apiErr.Error())
		return
	}

	cmd.ui.Ok()
	cmd.ui.Say("")

	if len(serviceOfferings) == 0 {
		cmd.ui.Say("No service offerings found")
		return
	}

	table := [][]string{
		[]string{"service", "plans", "description"},
	}

	sort.Sort(serviceOfferings)
	for _, offering := range serviceOfferings {
		planNames := ""

		for _, plan := range offering.Plans {
			if plan.Name == "" {
				continue
			}
			planNames = planNames + ", " + plan.Name
		}

		planNames = strings.TrimPrefix(planNames, ", ")

		table = append(table, []string{
			offering.Label,
			planNames,
			offering.Description,
		})
	}

	cmd.ui.DisplayTable(table)
	return
}
開發者ID:knolleary,項目名稱:cli,代碼行數:60,代碼來源:marketplace_services.go

示例3: Execute

func (req *buildpackApiRequirement) Execute() (success bool) {
	var apiErr errors.Error
	req.buildpack, apiErr = req.buildpackRepo.FindByName(req.name)

	if apiErr != nil {
		req.ui.Failed(apiErr.Error())
		return false
	}

	return true
}
開發者ID:knolleary,項目名稱:cli,代碼行數:11,代碼來源:buildpack.go

示例4: Execute

func (req *serviceInstanceApiRequirement) Execute() (success bool) {
	var apiErr errors.Error
	req.serviceInstance, apiErr = req.serviceRepo.FindInstanceByName(req.name)

	if apiErr != nil {
		req.ui.Failed(apiErr.Error())
		return false
	}

	return true
}
開發者ID:knolleary,項目名稱:cli,代碼行數:11,代碼來源:service_instance.go

示例5: Execute

func (req *organizationApiRequirement) Execute() (success bool) {
	var apiErr errors.Error
	req.org, apiErr = req.orgRepo.FindByName(req.name)

	if apiErr != nil {
		req.ui.Failed(apiErr.Error())
		return false
	}

	return true
}
開發者ID:knolleary,項目名稱:cli,代碼行數:11,代碼來源:organization.go

示例6: Execute

func (req *domainApiRequirement) Execute() bool {
	var apiErr errors.Error
	req.domain, apiErr = req.domainRepo.FindByNameInOrg(req.name, req.config.OrganizationFields().Guid)

	if apiErr != nil {
		req.ui.Failed(apiErr.Error())
		return false
	}

	return true
}
開發者ID:knolleary,項目名稱:cli,代碼行數:11,代碼來源:domain.go

示例7: Execute

func (req *applicationApiRequirement) Execute() (success bool) {
	var apiErr errors.Error
	req.application, apiErr = req.appRepo.Read(req.name)

	if apiErr != nil {
		req.ui.Failed(apiErr.Error())
		return false
	}

	return true
}
開發者ID:knolleary,項目名稱:cli,代碼行數:11,代碼來源:application.go

示例8: Execute

func (req *userApiRequirement) Execute() (success bool) {
	var apiErr errors.Error
	req.user, apiErr = req.userRepo.FindByUsername(req.username)

	if apiErr != nil {
		req.ui.Failed(apiErr.Error())
		return false
	}

	return true
}
開發者ID:knolleary,項目名稱:cli,代碼行數:11,代碼來源:user.go

示例9: domain

func (cmd *Push) domain(c *cli.Context, domainName string) (domain models.DomainFields) {
	var apiErr errors.Error

	if domainName != "" {
		domain, apiErr = cmd.domainRepo.FindByNameInOrg(domainName, cmd.config.OrganizationFields().Guid)
		if apiErr != nil {
			cmd.ui.Failed(apiErr.Error())
		}
		return
	}

	domain, err := cmd.findDefaultDomain()

	if err != nil {
		cmd.ui.Failed(err.Error())
	}

	if domain.Guid == "" {
		cmd.ui.Failed("No default domain exists")
	}

	return
}
開發者ID:knolleary,項目名稱:cli,代碼行數:23,代碼來源:push.go


注:本文中的cf/errors.Error類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。