@@ -38,7 +38,7 @@ protected Group GetGroup(object id, GroupPermission permissions)
3838 } ;
3939
4040 if ( group == null || ! group . CanUserViewGroup ( Context . User ) )
41- throw new GitLabNotFoundException ( "Group does not exist or user doesn't have permission to view it" ) ;
41+ throw GitLabException . NotFound ( "Group does not exist or user doesn't have permission to view it" ) ;
4242
4343 switch ( permissions )
4444 {
@@ -48,12 +48,12 @@ protected Group GetGroup(object id, GroupPermission permissions)
4848
4949 case GroupPermission . Edit :
5050 if ( ! group . CanUserEditGroup ( Context . User ) )
51- throw new GitLabForbiddenException ( $ "User '{ Context . User . Name } ' does not have the permission to edit the group '{ group . Name } '") ;
51+ throw GitLabException . Forbidden ( $ "User '{ Context . User . Name } ' does not have the permission to edit the group '{ group . Name } '") ;
5252 break ;
5353
5454 case GroupPermission . Delete :
5555 if ( ! group . CanUserDeleteGroup ( Context . User ) )
56- throw new GitLabForbiddenException ( $ "User '{ Context . User . Name } ' does not have the permission to delete the group '{ group . Name } '") ;
56+ throw GitLabException . Forbidden ( $ "User '{ Context . User . Name } ' does not have the permission to delete the group '{ group . Name } '") ;
5757 break ;
5858
5959 default :
@@ -85,8 +85,8 @@ protected Project GetProject(object id, ProjectPermission permissions)
8585 _ => throw new ArgumentException ( $ "Id of type '{ id . GetType ( ) } ' is not supported") ,
8686 } ;
8787
88- if ( project == null || ! project . CanUserViewProject ( Context . User ) )
89- throw new GitLabNotFoundException ( "Project does not exist or User doesn't have permission to view it" ) ;
88+ if ( project is null || ! project . CanUserViewProject ( Context . User ) )
89+ throw GitLabException . NotFound ( "Project does not exist or User doesn't have permission to view it" ) ;
9090
9191 switch ( permissions )
9292 {
@@ -96,17 +96,17 @@ protected Project GetProject(object id, ProjectPermission permissions)
9696
9797 case ProjectPermission . Contribute :
9898 if ( ! project . CanUserContributeToProject ( Context . User ) )
99- throw new GitLabForbiddenException ( $ "User '{ Context . User . Name } ' does not have the permission to contribute to the project '{ project . Name } '") ;
99+ throw GitLabException . Forbidden ( $ "User '{ Context . User . Name } ' does not have the permission to contribute to the project '{ project . Name } '") ;
100100 break ;
101101
102102 case ProjectPermission . Edit :
103103 if ( ! project . CanUserEditProject ( Context . User ) )
104- throw new GitLabForbiddenException ( $ "User '{ Context . User . Name } ' does not have the permission to edit the project '{ project . Name } '") ;
104+ throw GitLabException . Forbidden ( $ "User '{ Context . User . Name } ' does not have the permission to edit the project '{ project . Name } '") ;
105105 break ;
106106
107107 case ProjectPermission . Delete :
108108 if ( ! project . CanUserDeleteProject ( Context . User ) )
109- throw new GitLabForbiddenException ( $ "User '{ Context . User . Name } ' does not have the permission to delete the project '{ project . Name } '") ;
109+ throw GitLabException . Forbidden ( $ "User '{ Context . User . Name } ' does not have the permission to delete the project '{ project . Name } '") ;
110110 break ;
111111
112112 default :
@@ -120,7 +120,7 @@ protected User GetUser(long userId)
120120 {
121121 var user = Server . Users . GetById ( userId ) ;
122122 if ( user == null )
123- throw new GitLabNotFoundException ( ) ;
123+ throw GitLabException . NotFound ( ) ;
124124
125125 return user ;
126126 }
@@ -130,7 +130,7 @@ protected Issue GetIssue(long projectId, long issueId)
130130 var project = GetProject ( projectId , ProjectPermission . View ) ;
131131 var issue = project . Issues . GetByIid ( issueId ) ;
132132 if ( issue == null )
133- throw new GitLabNotFoundException ( ) ;
133+ throw GitLabException . NotFound ( ) ;
134134
135135 return issue ;
136136 }
@@ -140,7 +140,7 @@ protected Milestone GetMilestone(long projectId, long milestoneId)
140140 var project = GetProject ( projectId , ProjectPermission . View ) ;
141141 var milestone = project . Milestones . GetByIid ( milestoneId ) ;
142142 if ( milestone == null )
143- throw new GitLabNotFoundException ( ) ;
143+ throw GitLabException . NotFound ( ) ;
144144
145145 return milestone ;
146146 }
@@ -150,7 +150,7 @@ protected MergeRequest GetMergeRequest(long projectId, long mergeRequestIid)
150150 var project = GetProject ( projectId , ProjectPermission . View ) ;
151151 var mergeRequest = project . MergeRequests . GetByIid ( mergeRequestIid ) ;
152152 if ( mergeRequest == null )
153- throw new GitLabNotFoundException ( ) ;
153+ throw GitLabException . NotFound ( ) ;
154154
155155 return mergeRequest ;
156156 }
0 commit comments