Skip to content

Commit 12b58f4

Browse files
jankeromnesroboquat
authored andcommitted
[server] Introduce and use a ErrorCodes.INTERNAL_SERVER_ERROR
1 parent 4df5162 commit 12b58f4

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

components/gitpod-protocol/src/messaging/error.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ export namespace ErrorCodes {
6262
// 490 Too Many Running Workspace
6363
export const TOO_MANY_RUNNING_WORKSPACES = 490;
6464

65+
// 500 Internal Server Error
66+
export const INTERNAL_SERVER_ERROR = 500;
67+
6568
// 501 EE Feature
6669
export const EE_FEATURE = 501;
6770

components/server/ee/src/workspace/gitpod-server-impl.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ export class GitpodServerEEImpl extends GitpodServerImpl {
544544
res.rows = res.rows.map(this.censorUser);
545545
return res;
546546
} catch (e) {
547-
throw new ResponseError(500, e.toString());
547+
throw new ResponseError(ErrorCodes.INTERNAL_SERVER_ERROR, e.toString());
548548
}
549549
}
550550

@@ -559,7 +559,7 @@ export class GitpodServerEEImpl extends GitpodServerImpl {
559559
try {
560560
result = await this.userDB.findUserById(userId);
561561
} catch (e) {
562-
throw new ResponseError(500, e.toString());
562+
throw new ResponseError(ErrorCodes.INTERNAL_SERVER_ERROR, e.toString());
563563
}
564564

565565
if (!result) {
@@ -606,7 +606,7 @@ export class GitpodServerEEImpl extends GitpodServerImpl {
606606
try {
607607
await this.userDeletionService.deleteUser(userId);
608608
} catch (e) {
609-
throw new ResponseError(500, e.toString());
609+
throw new ResponseError(ErrorCodes.INTERNAL_SERVER_ERROR, e.toString());
610610
}
611611
}
612612

@@ -1862,7 +1862,7 @@ export class GitpodServerEEImpl extends GitpodServerImpl {
18621862
return setupIntent.client_secret || undefined;
18631863
} catch (error) {
18641864
log.error("Failed to create Stripe SetupIntent", error);
1865-
throw new ResponseError(500, "Failed to create Stripe SetupIntent");
1865+
throw new ResponseError(ErrorCodes.INTERNAL_SERVER_ERROR, "Failed to create Stripe SetupIntent");
18661866
}
18671867
}
18681868

@@ -1875,7 +1875,10 @@ export class GitpodServerEEImpl extends GitpodServerImpl {
18751875
return customer?.id || undefined;
18761876
} catch (error) {
18771877
log.error(`Failed to get Stripe Customer ID for team '${teamId}'`, error);
1878-
throw new ResponseError(500, `Failed to get Stripe Customer ID for team '${teamId}'`);
1878+
throw new ResponseError(
1879+
ErrorCodes.INTERNAL_SERVER_ERROR,
1880+
`Failed to get Stripe Customer ID for team '${teamId}'`,
1881+
);
18791882
}
18801883
}
18811884

@@ -1889,7 +1892,7 @@ export class GitpodServerEEImpl extends GitpodServerImpl {
18891892
// TODO(janx): Create a Stripe usage-based Subscription for the customer
18901893
} catch (error) {
18911894
log.error(`Failed to subscribe team '${teamId}' to Stripe`, error);
1892-
throw new ResponseError(500, `Failed to subscribe team '${teamId}' to Stripe`);
1895+
throw new ResponseError(ErrorCodes.INTERNAL_SERVER_ERROR, `Failed to subscribe team '${teamId}' to Stripe`);
18931896
}
18941897
}
18951898

components/server/src/websocket/websocket-connection-manager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ class GitpodJsonRpcProxyFactory<T extends object> extends JsonRpcProxyFactory<T>
433433
} else {
434434
TraceContext.setError(ctx, e); // this is a "real" error
435435

436-
const err = new ResponseError(500, "internal server error");
436+
const err = new ResponseError(ErrorCodes.INTERNAL_SERVER_ERROR, "internal server error");
437437
increaseApiCallCounter(method, err.code);
438438
TraceContext.setJsonRPCError(ctx, method, err, true);
439439

0 commit comments

Comments
 (0)