Fixed communicating errors to the user

This commit is contained in:
kolaente 2018-01-11 21:22:39 +01:00 committed by Konrad
parent d5b1c33f73
commit 5f187df6b2
No known key found for this signature in database
GPG Key ID: F40E70337AB24C9B
3 changed files with 10 additions and 10 deletions

View File

@ -10,7 +10,6 @@ import (
"fmt" "fmt"
"io" "io"
"io/ioutil" "io/ioutil"
"net/http"
"strconv" "strconv"
"strings" "strings"
"time" "time"
@ -712,7 +711,7 @@ func ViewIssue(ctx *context.Context) {
} }
} else if comment.Type == models.CommentTypeRemoveDependency || comment.Type == models.CommentTypeAddDependency { } else if comment.Type == models.CommentTypeRemoveDependency || comment.Type == models.CommentTypeAddDependency {
if err = comment.LoadDepIssueDetails(); err != nil { if err = comment.LoadDepIssueDetails(); err != nil {
ctx.Handle(http.StatusInternalServerError, "LoadDepIssueDetails", err) ctx.ServerError("LoadDepIssueDetails", err)
return return
} }
} }

View File

@ -20,13 +20,13 @@ func AddDependency(ctx *context.Context) {
issueIndex := ctx.ParamsInt64("index") issueIndex := ctx.ParamsInt64("index")
issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, issueIndex) issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, issueIndex)
if err != nil { if err != nil {
ctx.Handle(http.StatusInternalServerError, "GetIssueByIndex", err) ctx.ServerError("GetIssueByIndex", err)
return return
} }
// Check if the Repo is allowed to have dependencies // Check if the Repo is allowed to have dependencies
if !ctx.Repo.CanCreateIssueDependencies(issue, ctx.User) { if !ctx.Repo.CanCreateIssueDependencies(issue, ctx.User) {
ctx.Handle(404, "NotAllowedToCreateIssueDependencies", nil) ctx.NotFound("NotAllowedToCreateIssueDependencies", nil)
return return
} }
@ -58,7 +58,7 @@ func AddDependency(ctx *context.Context) {
} else if models.IsErrCircularDependency(err) { } else if models.IsErrCircularDependency(err) {
ctx.Flash.Error(ctx.Tr("repo.issues.dependency.add_error_cannot_create_circular")) ctx.Flash.Error(ctx.Tr("repo.issues.dependency.add_error_cannot_create_circular"))
} else { } else {
ctx.Handle(http.StatusInternalServerError, "CreateOrUpdateIssueDependency", err) ctx.ServerError("CreateOrUpdateIssueDependency", err)
return return
} }
} }

View File

@ -19,13 +19,13 @@ func RemoveDependency(ctx *context.Context) {
issueIndex := ctx.ParamsInt64("index") issueIndex := ctx.ParamsInt64("index")
issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, issueIndex) issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, issueIndex)
if err != nil { if err != nil {
ctx.Handle(http.StatusInternalServerError, "GetIssueByIndex", err) ctx.ServerError("GetIssueByIndex", err)
return return
} }
// Check if the Repo is allowed to have dependencies // Check if the Repo is allowed to have dependencies
if !ctx.Repo.CanCreateIssueDependencies(issue, ctx.User) { if !ctx.Repo.CanCreateIssueDependencies(issue, ctx.User) {
ctx.Handle(404, "NotAllowedToCreateIssueDependencies", nil) ctx.NotFound("NotAllowedToCreateIssueDependencies", nil)
return return
} }
@ -40,19 +40,20 @@ func RemoveDependency(ctx *context.Context) {
case "blocking": case "blocking":
depType = models.DependencyTypeBlocking depType = models.DependencyTypeBlocking
default: default:
ctx.Handle(http.StatusBadRequest, "GetDependecyType", nil) ctx.Error(http.StatusBadRequest, "GetDependecyType")
//ctx.Handle(http.StatusBadRequest, "GetDependecyType", nil)
return return
} }
// Dependency // Dependency
dep, err := models.GetIssueByID(depID) dep, err := models.GetIssueByID(depID)
if err != nil { if err != nil {
ctx.Handle(http.StatusInternalServerError, "GetIssueByID", err) ctx.ServerError("GetIssueByID", err)
return return
} }
if err = models.RemoveIssueDependency(ctx.User, issue, dep, depType); err != nil { if err = models.RemoveIssueDependency(ctx.User, issue, dep, depType); err != nil {
ctx.Handle(http.StatusInternalServerError, "RemoveIssueDependency", err) ctx.ServerError("RemoveIssueDependency", err)
return return
} }