mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 08:30:25 +08:00 
			
		
		
		
	make sure to catch the right error so it is displayed as an error on the ui not a 500 (#4945)
This commit is contained in:
		@@ -732,7 +732,7 @@ func AddDeployKey(repoID int64, name, content string, readOnly bool) (*DeployKey
 | 
			
		||||
 | 
			
		||||
	key, err := addDeployKey(sess, pkey.ID, repoID, name, pkey.Fingerprint, accessMode)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("addDeployKey: %v", err)
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return key, sess.Commit()
 | 
			
		||||
 
 | 
			
		||||
@@ -586,7 +586,7 @@ func DeployKeysPost(ctx *context.Context, form auth.AddKeyForm) {
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		ctx.Data["HasError"] = true
 | 
			
		||||
		switch {
 | 
			
		||||
		case models.IsErrKeyAlreadyExist(err):
 | 
			
		||||
		case models.IsErrDeployKeyAlreadyExist(err):
 | 
			
		||||
			ctx.Data["Err_Content"] = true
 | 
			
		||||
			ctx.RenderWithErr(ctx.Tr("repo.settings.key_been_used"), tplDeployKeys, &form)
 | 
			
		||||
		case models.IsErrKeyNameAlreadyUsed(err):
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user