mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-31 20:02:09 +00:00
Handle refactor (#3339)
* Replace all ctx.Handle with ctx.ServerError or ctx.NotFound * Change Handle(403) to NotFound, avoid using macaron's NotFound
This commit is contained in:
parent
45c264f681
commit
65861900cd
48 changed files with 622 additions and 610 deletions
|
@ -30,7 +30,7 @@ func GetNotificationCount(c *context.Context) {
|
|||
|
||||
count, err := models.GetNotificationCount(c.User, models.NotificationStatusUnread)
|
||||
if err != nil {
|
||||
c.Handle(500, "GetNotificationCount", err)
|
||||
c.ServerError("GetNotificationCount", err)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -62,13 +62,13 @@ func Notifications(c *context.Context) {
|
|||
statuses := []models.NotificationStatus{status, models.NotificationStatusPinned}
|
||||
notifications, err := models.NotificationsForUser(c.User, statuses, page, perPage)
|
||||
if err != nil {
|
||||
c.Handle(500, "ErrNotificationsForUser", err)
|
||||
c.ServerError("ErrNotificationsForUser", err)
|
||||
return
|
||||
}
|
||||
|
||||
total, err := models.GetNotificationCount(c.User, status)
|
||||
if err != nil {
|
||||
c.Handle(500, "ErrGetNotificationCount", err)
|
||||
c.ServerError("ErrGetNotificationCount", err)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -100,12 +100,12 @@ func NotificationStatusPost(c *context.Context) {
|
|||
case "pinned":
|
||||
status = models.NotificationStatusPinned
|
||||
default:
|
||||
c.Handle(500, "InvalidNotificationStatus", errors.New("Invalid notification status"))
|
||||
c.ServerError("InvalidNotificationStatus", errors.New("Invalid notification status"))
|
||||
return
|
||||
}
|
||||
|
||||
if err := models.SetNotificationStatus(notificationID, c.User, status); err != nil {
|
||||
c.Handle(500, "SetNotificationStatus", err)
|
||||
c.ServerError("SetNotificationStatus", err)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -117,7 +117,7 @@ func NotificationStatusPost(c *context.Context) {
|
|||
func NotificationPurgePost(c *context.Context) {
|
||||
err := models.UpdateNotificationStatuses(c.User, models.NotificationStatusUnread, models.NotificationStatusRead)
|
||||
if err != nil {
|
||||
c.Handle(500, "ErrUpdateNotificationStatuses", err)
|
||||
c.ServerError("ErrUpdateNotificationStatuses", err)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue