use plain error type for expected behaviors (#447)
This commit is contained in:
		
							parent
							
								
									15585ef12e
								
							
						
					
					
						commit
						65aa18300d
					
				@ -105,7 +105,7 @@ func editDDNS(c *gin.Context) error {
 | 
			
		||||
 | 
			
		||||
	var p model.DDNSProfile
 | 
			
		||||
	if err = singleton.DB.First(&p, id).Error; err != nil {
 | 
			
		||||
		return newGormError("%v", err)
 | 
			
		||||
		return fmt.Errorf("profile id %d does not exist", id)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	p.Name = df.Name
 | 
			
		||||
 | 
			
		||||
@ -1,6 +1,7 @@
 | 
			
		||||
package controller
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"strconv"
 | 
			
		||||
 | 
			
		||||
@ -36,7 +37,7 @@ func editServer(c *gin.Context) error {
 | 
			
		||||
 | 
			
		||||
	var s model.Server
 | 
			
		||||
	if err := singleton.DB.First(&s, id).Error; err != nil {
 | 
			
		||||
		return newGormError("%v", err)
 | 
			
		||||
		return fmt.Errorf("server id %d does not exist", id)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	s.Name = sf.Name
 | 
			
		||||
 | 
			
		||||
@ -113,7 +113,7 @@ func newServerGroup(c *gin.Context) error {
 | 
			
		||||
// @Param body body model.ServerGroupForm true "ServerGroupForm"
 | 
			
		||||
// @Produce json
 | 
			
		||||
// @Success 200 {object} model.CommonResponse[any]
 | 
			
		||||
// @Router /server-group/{id} [put]
 | 
			
		||||
// @Router /server-group/{id} [patch]
 | 
			
		||||
func editServerGroup(c *gin.Context) error {
 | 
			
		||||
	id := c.Param("id")
 | 
			
		||||
	var sg model.ServerGroupForm
 | 
			
		||||
@ -122,7 +122,7 @@ func editServerGroup(c *gin.Context) error {
 | 
			
		||||
	}
 | 
			
		||||
	var sgDB model.ServerGroup
 | 
			
		||||
	if err := singleton.DB.First(&sgDB, id).Error; err != nil {
 | 
			
		||||
		return newGormError("%v", err)
 | 
			
		||||
		return fmt.Errorf("group id %s does not exist", id)
 | 
			
		||||
	}
 | 
			
		||||
	sgDB.Name = sg.Name
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user