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

View File

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

View File

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