• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang beego.Error函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/astaxie/beego.Error函数的典型用法代码示例。如果您正苦于以下问题:Golang Error函数的具体用法?Golang Error怎么用?Golang Error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了Error函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: Search

func (c *WptController) Search() {
	if c.Ctx.Input.IsGet() {
		beego.Debug("WptController Search Get")
	}
	if c.Ctx.Input.IsPost() {
		beego.Debug("WptController Search Post")
	}
	search := c.Input().Get("search")
	if len(search) != 0 {
		objs, err := models.GetAllWptLike(search)
		if err != nil {
			beego.Error(err)
		}
		beego.Debug("Search :", objs)
		c.Data["Objs"] = objs
	} else {
		objs, err := models.GetAllWpt()
		if err != nil {
			beego.Error(err)
		}
		c.Data["Objs"] = objs

	}

	c.TplName = "wptsearch.html"
}
开发者ID:424626154,项目名称:Qax580_GoServer,代码行数:26,代码来源:wpt.go


示例2: parseDocs

func parseDocs() {
	root, err := ParseDocs("docs/zh-CN")
	if err != nil {
		beego.Error(err)
	}

	if root != nil {
		docs["zh-CN"] = root
	}

	root, err = ParseDocs("docs/en-US")
	if err != nil {
		beego.Error(err)
	}

	if root != nil {
		docs["en-US"] = root
	}

	root, err = ParseDocs("docs/ru-RU")
	if err != nil {
		beego.Error(err)
	}

	if root != nil {
		docs["ru-RU"] = root
	}
}
开发者ID:flying99999,项目名称:beeweb,代码行数:28,代码来源:models.go


示例3: crawlDoc

// crawlDoc fetchs package from VCS.
func crawlDoc(path string, etag string, views int64) (pdoc *Package, err error) {
	// I have no idea what the fuck does this mean.
	if i := strings.Index(path, "/libgo/go/"); i > 0 && utils.IsGoRepoPath(path[i+len("/libgo/go/"):]) {
		// Go Frontend source tree mirror.
		pdoc = nil
		err = errors.New("Go Frontend source tree mirror.")
	} else {
		var pdocNew *Package
		pdocNew, err = getRepo(httpClient, path, etag)

		// For timeout logic in client.go to work, we cannot leave connections idling. This is ugly.
		httpTransport.CloseIdleConnections()

		if err != errNotModified && pdocNew != nil {
			pdoc = pdocNew
			pdoc.Views = views
		}
	}

	switch {
	case err == nil:
		pdoc.Views = views
		if err = SaveProject(pdoc); err != nil {
			beego.Error("doc.SaveProject(", path, "):", err)
		}
	case isNotFound(err):
		// We do not need to delete standard library, so here is fine.
		if err = models.DeleteProject(path); err != nil {
			beego.Error("doc.DeleteProject(", path, "):", err)
		}
	}
	return pdoc, err
}
开发者ID:skelterjohn,项目名称:gowalker,代码行数:34,代码来源:crawl.go


示例4: AddGroup

func (c *ApiController) AddGroup() {
	var (
		err    error
		stores []string
		racks  int
		copys  int
		res    map[string]interface{} = make(map[string]interface{})
	)

	res["success"] = true

	stores = strings.Split(c.GetString("stores"), ",")

	if racks, err = c.GetInt("racks"); err != nil {
		beego.Error(err)
		c.responseError(err)
	}

	if copys, err = c.GetInt("copys"); err != nil {
		beego.Error(err)
		c.responseError(err)
	}

	if err = ops.OpsManager.AddGroup(stores, racks, copys); err != nil {
		beego.Error(err)
		c.responseError(err)
	}

	c.Data["json"] = res
	c.ServeJSON()
}
开发者ID:Terry-Mao,项目名称:bfs,代码行数:31,代码来源:api.go


示例5: updateImportInfo

func updateImportInfo(q *qbs.Qbs, path string, pid int, add bool) {
	// Save package information.
	info := new(PkgInfo)
	err := q.WhereEqual("path", path).Find(info)
	if err == nil {
		// Check if pid exists in this project.
		i := strings.Index(info.ImportPid, "$"+strconv.Itoa(pid)+"|")
		switch {
		case i == -1 && add: // Add operation and does not contain.
			info.ImportPid += "$" + strconv.Itoa(pid) + "|"
			info.ImportedNum++
			_, err = q.Save(info)
			if err != nil {
				beego.Error("models.updateImportInfo(): add:", path, err)
			}
		case i > -1 && !add: // Delete operation and contains.
			info.ImportPid = strings.Replace(info.ImportPid, "$"+strconv.Itoa(pid)+"|", "", 1)
			info.ImportedNum--
			_, err = q.Save(info)
			if err != nil {
				beego.Error("models.updateImportInfo(): delete:", path, err)
			}
		}
	}

	// Error means this project does not exist, simply skip.
}
开发者ID:richardjoo,项目名称:gowalker,代码行数:27,代码来源:models.go


示例6: Post

func (c *LoginController) Post() {
	account := c.Input().Get("account")
	password := c.Input().Get("password")
	autologin := c.Input().Get("autologin") == "on"

	//数据库比较
	pass, err := models.VerifyUser(common.MakeMD5(account), common.MakeMD5(password))
	if err != nil {
		c.Redirect("/login", 301)
		beego.Error(err)
		return
	}
	if pass {
		beego.Error("login successful!")
		maxage := 0
		if autologin {
			maxage = 1<<31 - 1
		}
		c.Ctx.SetCookie("account", common.MakeMD5(account), maxage, "/")
		c.Ctx.SetCookie("password", common.MakeMD5(password), maxage, "/")

		c.SetSession("account", common.MakeMD5(account))
		// c.SetSession("password", password)
	} else {
		c.Redirect("/login", 301)
		beego.Error("login failed!")
		return
	}
	c.Redirect("/", 301)
	return
}
开发者ID:danuxguin,项目名称:web4blog,代码行数:31,代码来源:login.go


示例7: AddVolume

func (c *ApiController) AddVolume() {
	var (
		err     error
		groupId int64
		n       int
		res     map[string]interface{} = make(map[string]interface{})
	)

	res["success"] = true

	if groupId, err = c.GetInt64("groupId"); err != nil {
		beego.Error(err)
		c.responseError(err)
	}

	if n, err = c.GetInt("n"); err != nil {
		beego.Error(err)
		c.responseError(err)
	}

	if err = ops.OpsManager.AddVolume(uint64(groupId), n); err != nil {
		beego.Error(err)
		c.responseError(err)
	}

	c.Data["json"] = res
	c.ServeJSON()
}
开发者ID:Terry-Mao,项目名称:bfs,代码行数:28,代码来源:api.go


示例8: initDb

func initDb() {
	iniconf, err := config.NewConfig("ini", "conf/app.conf")
	if err != nil {
		beego.Error(err)
	}
	driverName := iniconf.String("orm::driver_name")
	dataSource := iniconf.String("orm::data_source")
	maxIdle, _ := iniconf.Int("orm::max_idle_conn")
	maxOpen, _ := iniconf.Int("orm::max_open_conn")

	// set default database
	err = orm.RegisterDataBase("default", driverName, dataSource, maxIdle, maxOpen)
	if err != nil {
		beego.Error(err)
	}
	//	orm.Debug = true

	//orm.RunCommand()							//执行命令行的

	err = orm.RunSyncdb("default", false, false) //建表的
	////数据库别名,不强制建数据库,打印建表过程

	if err != nil {
		beego.Error(err)
	}
}
开发者ID:oyoy8629,项目名称:hellodb,代码行数:26,代码来源:init.go


示例9: AdminGua

func (c *DqsjController) AdminGua() {
	bool, _ := chackDqsjAccount(c.Ctx)
	if bool {

	} else {
		c.Redirect("/dqsj/adminlogin", 302)
		return
	}
	if c.Ctx.Input.IsGet() {
		beego.Debug("AdminGua Get")
	}
	if c.Ctx.Input.IsPost() {
		beego.Debug("AdminGua Post")
	}
	op := c.Input().Get("op")
	beego.Debug("op :", op)
	switch op {
	case "del":
		id := c.Input().Get("id")
		err := models.DeleteGuaItem(id)
		if err != nil {
			beego.Error(err)
		}
		c.Redirect("/dqsj/admingua", 302)
		return
	case "state0":
		id := c.Input().Get("id")
		err := models.UpdateGuaItem(id, 1)
		if err != nil {
			beego.Error(err)
		}
		c.Redirect("/dqsj/admingua", 302)
		return
	case "state1":
		id := c.Input().Get("id")
		err := models.UpdateGuaItem(id, 0)
		if err != nil {
			beego.Error(err)
		}
		c.Redirect("/dqsj/admingua", 302)
		return
	}
	panitem, err := models.GetAllGuaItem()
	if err != nil {
		beego.Error(err)
	}
	//计算总概率
	allProbability := int64(0)
	for i := 0; i < len(panitem); i++ {
		if panitem[i].State == 1 {
			allProbability += panitem[i].Probability
		}
	}
	for i := 0; i < len(panitem); i++ {
		panitem[i].AllProbability = allProbability
	}
	c.Data["GuaItem"] = panitem

	c.TplName = "dqsjadmingua.html"
}
开发者ID:424626154,项目名称:Qax580_GoServer,代码行数:60,代码来源:dqsj.go


示例10: Remove

func (c *Comments) Remove() {

	r := RJson{Msg: T("internal")}
	c.Data["json"] = &r

	i := c.GetSession("role")
	if i == nil || i.(int) != M.RoleAdmin {
		r.Msg = T("restrict_access")
		return
	}

	id, err := strconv.Atoi(c.Ctx.Input.Param(":id"))
	if err != nil {
		beego.Error(err)
		return
	}

	err = DM.DeleteByPk(&M.Comment{}, id)
	if err != nil {
		beego.Error(err)
		return
	}

	r.Msg = ""
	r.Success = true
}
开发者ID:grr89,项目名称:hrkb,代码行数:26,代码来源:comment.go


示例11: Get

func (this *CategoryController) Get() {
	this.Data["headerTitle"] = "Categories"
	this.TplNames = "category.html"
	this.Data["isCategory"] = true
	this.Data["isLogin"] = checkLogin(this.Ctx)

	op := this.Input().Get("op")
	if op == "add" {
		name := this.Input().Get("name")
		err := models.AddCategory(name)
		if err != nil {
			beego.Error(err)
		}
	} else if op == "del" {
		id := this.Input().Get("id")
		err := models.DeleteCategory(id)
		if err != nil {
			beego.Error(err)
		}
	}
	var err error
	this.Data["Categories"], err = models.AllCategories(false)
	if err != nil {
		beego.Error(err)
	}
}
开发者ID:zhao-l-c,项目名称:goblog,代码行数:26,代码来源:categoryController.go


示例12: Get

func (this *MainController) Get() {
	page, err := this.GetInt64("p", 1)
	if err != nil {
		beego.Error(err)
	}

	extend := map[string]string{}
	tid := this.GetString("tid", "")
	key := this.GetString("key")
	if tid != "" {
		extend["type_id"] = tid
	}

	beego.Info(extend)
	maps, err := models.GetArtPageList(10, (page-1)*10, extend, key)

	if err != nil {
		beego.Error(err)
	}
	count, err := models.GetCount(extend, key)
	if err != nil {
		beego.Error(err)
	}
	p := pagination.NewPaginator(this.Ctx.Request, 10, count)
	beego.Info(p)
	this.Data["paginator"] = p
	types := models.GetAllType()
	this.Data["articles"] = maps
	this.Data["types"] = types
	this.Data["key"] = key
	beego.AppConfig.String("banner1.name")

	this.TplNames = "index.tpl"
}
开发者ID:sshitaime,项目名称:myblog,代码行数:34,代码来源:index.go


示例13: Prepare

func (this *ConfigController) Prepare() {
	banner1_url := beego.AppConfig.String("banner1.url")
	banner1_id, _ := beego.AppConfig.Int("banner1.id")
	art := models.Article{Id: banner1_id}
	err := models.GetByProperty(&art)
	if err != nil {
		beego.Error(err)
	}
	this.Data["banner1_url"] = banner1_url
	this.Data["banner1_art"] = art

	banner2_url := beego.AppConfig.String("banner2.url")
	banner2_id, _ := beego.AppConfig.Int("banner2.id")
	art2 := models.Article{Id: banner2_id}
	err2 := models.GetByProperty(&art2)
	if err2 != nil {
		beego.Error(err)
	}
	this.Data["banner2_url"] = banner2_url
	this.Data["banner2_art"] = art2

	banner3_url := beego.AppConfig.String("banner3.url")
	banner3_id, _ := beego.AppConfig.Int("banner3.id")
	art3 := models.Article{Id: banner3_id}
	err3 := models.GetByProperty(&art3)
	if err3 != nil {
		beego.Error(err)
	}
	this.Data["banner3_url"] = banner3_url
	this.Data["banner3_art"] = art3
}
开发者ID:sshitaime,项目名称:myblog,代码行数:31,代码来源:index.go


示例14: Get

func (c *AdminNoticeController) Get() {
	bool, username := chackAccount(c.Ctx)
	if bool {

	} else {
		c.Redirect("/admin", 302)
		return
	}
	c.Data["isUser"] = bool
	c.Data["User"] = username
	op := c.Input().Get("op")
	switch op {
	case "del":
		id := c.Input().Get("id")
		err := models.DeleteAdminUserNotice(id)
		if err != nil {
			beego.Error(err)
		}
		c.Redirect("/admin/notice", 302)
		return
	}
	objs, err := models.GetAllNotice()
	if err != nil {
		beego.Error(objs)
	}
	c.Data["Objs"] = objs
	c.TplName = "adminnotice.html"
}
开发者ID:424626154,项目名称:Qax580_GoServer,代码行数:28,代码来源:adminnotice.go


示例15: Get

func (this *HomeController) Get() {
	this.Data["IsHome"] = true
	this.TplNames = "home.html"

	this.Data["IsLogin"] = checkAccount(this.Ctx)

	category := this.Input().Get("cate")

	var err error
	topics := make([]*models.Topic, 0)

	if len(category) == 0 {
		topics, err = models.GetAllTopics(true)
	} else {
		topics, err = models.GetTopicsByCategory(category, true)
	}
	if err != nil {
		beego.Error(err)
	}
	this.Data["Topics"] = topics

	Category, err := models.GetAllCategories()
	if err != nil {
		beego.Error(err)
	}

	this.Data["Categories"] = Category

}
开发者ID:GuoBug,项目名称:beeblog,代码行数:29,代码来源:controllers.go


示例16: Handler

// Handler beego filter handler for serve captcha image
func (c *Captcha) Handler(ctx *context.Context) {
	var chars []byte

	id := path.Base(ctx.Request.RequestURI)
	if i := strings.Index(id, "."); i != -1 {
		id = id[:i]
	}

	key := c.key(id)

	if len(ctx.Input.Query("reload")) > 0 {
		chars = c.genRandChars()
		if err := c.store.Put(key, chars, c.Expiration); err != nil {
			ctx.Output.SetStatus(500)
			ctx.WriteString("captcha reload error")
			beego.Error("Reload Create Captcha Error:", err)
			return
		}
	} else {
		if v, ok := c.store.Get(key).([]byte); ok {
			chars = v
		} else {
			ctx.Output.SetStatus(404)
			ctx.WriteString("captcha not found")
			return
		}
	}

	img := NewImage(chars, c.StdWidth, c.StdHeight)
	if _, err := img.WriteTo(ctx.ResponseWriter); err != nil {
		beego.Error("Write Captcha Image Error:", err)
	}
}
开发者ID:kingljl,项目名称:beego,代码行数:34,代码来源:captcha.go


示例17: LoadPkgDoc

// LoadPkgDoc loads project introduction documentation.
func LoadPkgDoc(path, lang, docType string) (doc string) {
	if len(lang) < 2 {
		return ""
	}

	lang = lang[:2]

	pdoc := &PkgDoc{
		Path: path,
		Lang: lang,
		Type: docType,
	}

	if has, err := x.Get(pdoc); has {
		if err != nil {
			beego.Error("models.LoadPkgDoc(", path, lang, docType,
				") -> Fail to get PkgDoc:", err.Error())
			return doc
		}
		return pdoc.Doc
	}

	pdoc.Lang = "en"
	if has, err := x.Get(pdoc); has {
		if err != nil {
			beego.Error("models.LoadPkgDoc(", path,
				") -> Fail to get PkgDoc:", err.Error())
			return doc
		}
		return pdoc.Doc
	}
	return doc
}
开发者ID:juju2013,项目名称:gowalker,代码行数:34,代码来源:models.go


示例18: Post

func (this *MainController) Post() {
	body, err := ioutil.ReadAll(this.Ctx.Request.Body)
	if err != nil {
		beego.Error(err)
		this.Ctx.ResponseWriter.WriteHeader(500)
		return
	}
	beego.Info(string(body))
	var wreq *Request
	if wreq, err = DecodeRequest(body); err != nil {
		beego.Error(err)
		this.Ctx.ResponseWriter.WriteHeader(500)
		return
	}
	beego.Info(wreq.Content)
	wresp, err := dealwith(wreq)
	if err != nil {
		beego.Error(err)
		this.Ctx.ResponseWriter.WriteHeader(500)
		return
	}
	data, err := wresp.Encode()
	if err != nil {
		beego.Error(err)
		this.Ctx.ResponseWriter.WriteHeader(500)
		return
	}
	this.Ctx.WriteString(string(data))
	return
}
开发者ID:qinglong1983,项目名称:weixin,代码行数:30,代码来源:default.go


示例19: GetCacheUserData

func GetCacheUserData(token string) (userData *m.UserData) {

	if redisx == nil {
		return nil
	}
	v := redisx.Get("USERDATA_" + token)

	if v != nil {

		bJson, err := lib.GetBytes(v)
		if err != nil {
			beego.Error(err.Error())
			return nil
		}

		beego.Debug("Get cache user data:" + string(bJson))

		err = json.Unmarshal(bJson, &userData)
		if err != nil {
			beego.Error(err.Error())
			return nil
		}

	}

	return userData
}
开发者ID:wfnuser,项目名称:o2oadmin,代码行数:27,代码来源:ApiBaseController.go


示例20: Post

func (this *OpsController) Post() {
	agentId := this.GetString("agent_id")
	action := this.GetString("action")

	switch action {
	case "":
		monitorStr, err := getMonitorByAgentId(agentId)
		if err != nil {
			this.Data["AgentError"] = fmt.Sprintf("Request AgentId [%s] monitor info error: %s", agentId, err)
			beego.Error("Request AgentId [%s] monitor info error: %s", agentId, err)
		} else {
			err = saveOrUpdateMonitor(monitorStr)
			this.Data["AgentError"] = fmt.Sprintf("Save error: %s", err)
			beego.Error("saveOrUpdateMonitor monitorStr [%s] Error %s", monitorStr, err)
		}
	case "delete":
		monitor := entity.Monitor{}
		monitor.AgentId = agentId
		err := monitor.DeleteByAgentId()
		if err != nil {
			this.Data["AgentError"] = fmt.Sprintf("Delete Monitor error %s", err)
		}
	}

	this.Get()
}
开发者ID:alex8023,项目名称:citycloud.cf-deploy-ui,代码行数:26,代码来源:ops.go



注:本文中的github.com/astaxie/beego.Error函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang beego.ErrorController函数代码示例发布时间:2022-05-24
下一篇:
Golang beego.Debug函数代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap