@@ -19,6 +19,7 @@ import {
19
19
ListConfigurationsResponse ,
20
20
} from "@gitpod/public-api/lib/gitpod/v1/configuration_pb" ;
21
21
import { PaginationResponse } from "@gitpod/public-api/lib/gitpod/v1/pagination_pb" ;
22
+ import { ApplicationError , ErrorCodes } from "@gitpod/gitpod-protocol/lib/messaging/error" ;
22
23
23
24
@injectable ( )
24
25
export class ConfigurationServiceAPI implements ServiceImpl < typeof ConfigurationServiceInterface > {
@@ -34,13 +35,13 @@ export class ConfigurationServiceAPI implements ServiceImpl<typeof Configuration
34
35
context : HandlerContext ,
35
36
) : Promise < CreateConfigurationResponse > {
36
37
if ( ! req . organizationId ) {
37
- throw new Error ( "organizationId is required" ) ;
38
+ throw new ApplicationError ( ErrorCodes . BAD_REQUEST , "organizationId is required" ) ;
38
39
}
39
40
if ( ! req . cloneUrl ) {
40
- throw new Error ( "cloneUrl is required" ) ;
41
+ throw new ApplicationError ( ErrorCodes . BAD_REQUEST , "cloneUrl is required" ) ;
41
42
}
42
43
if ( ! req . name ) {
43
- throw new Error ( "name is required" ) ;
44
+ throw new ApplicationError ( ErrorCodes . BAD_REQUEST , "name is required" ) ;
44
45
}
45
46
46
47
const project = await this . projectService . createProject (
@@ -61,7 +62,7 @@ export class ConfigurationServiceAPI implements ServiceImpl<typeof Configuration
61
62
62
63
async getConfiguration ( req : GetConfigurationRequest , context : HandlerContext ) {
63
64
if ( ! req . configurationId ) {
64
- throw new Error ( "configurationId is required" ) ;
65
+ throw new ApplicationError ( ErrorCodes . BAD_REQUEST , "configurationId is required" ) ;
65
66
}
66
67
67
68
const project = await this . projectService . getProject ( context . user . id , req . configurationId ) ;
@@ -73,7 +74,7 @@ export class ConfigurationServiceAPI implements ServiceImpl<typeof Configuration
73
74
74
75
async listConfigurations ( req : ListConfigurationsRequest , context : HandlerContext ) {
75
76
if ( ! req . organizationId ) {
76
- throw new Error ( "organizationId is required" ) ;
77
+ throw new ApplicationError ( ErrorCodes . BAD_REQUEST , "organizationId is required" ) ;
77
78
}
78
79
79
80
const { rows, total } = await this . projectService . findProjects ( context . user . id , {
@@ -94,7 +95,7 @@ export class ConfigurationServiceAPI implements ServiceImpl<typeof Configuration
94
95
95
96
async deleteConfiguration ( req : DeleteConfigurationRequest , handler : HandlerContext ) {
96
97
if ( ! req . configurationId ) {
97
- throw new Error ( "configurationId is required" ) ;
98
+ throw new ApplicationError ( ErrorCodes . BAD_REQUEST , "configurationId is required" ) ;
98
99
}
99
100
100
101
await this . projectService . deleteProject ( handler . user . id , req . configurationId ) ;
0 commit comments