gitea源码

helper.go 566B

1234567891011121314151617181920
  1. // Copyright 2023 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package repo
  4. import (
  5. "code.gitea.io/gitea/modules/git"
  6. "code.gitea.io/gitea/services/context"
  7. )
  8. func HandleGitError(ctx *context.Context, msg string, err error) {
  9. if git.IsErrNotExist(err) {
  10. ctx.Data["NotFoundPrompt"] = ctx.Locale.Tr("repo.tree_path_not_found", ctx.Repo.TreePath, ctx.Repo.RefTypeNameSubURL())
  11. ctx.Data["NotFoundGoBackURL"] = ctx.Repo.RepoLink + "/src/" + ctx.Repo.RefTypeNameSubURL()
  12. ctx.NotFound(err)
  13. } else {
  14. ctx.ServerError(msg, err)
  15. }
  16. }