Skip to content

Commit

Permalink
update invalid port copy
Browse files Browse the repository at this point in the history
  • Loading branch information
camden11 committed Nov 8, 2023
1 parent 825d86b commit bd1e9cb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@
},
"detectPort": {
"errors": {
"invalidPort": "Port must be between 1024 and 65535"
"invalidPort": "Port must be between {{ minPort }} and {{ maxPort }}"
}
},
"PortManagerServer": {
Expand All @@ -337,7 +337,7 @@
"duplicateInstance": "Failed to start PortManagerServer. An instance of PortManagerServer is already running.",
"404": "Could not find a server with instanceId {{ instanceId }}",
"409": "Failed to assign port. Server with instanceId {{ instanceId }} is already running on port {{ port }}",
"400": "Invalid port requested. Port must be between 1024 and 65535."
"400": "Invalid port requested. Port must be between {{ minPort }} and {{ maxPort }}."
}
}
},
Expand Down
7 changes: 6 additions & 1 deletion utils/PortManagerServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,12 @@ class PortManagerServer {
);
return;
} else if (port && (port < MIN_PORT_NUMBER || port > MAX_PORT_NUMBER)) {
res.status(400).send(i18n(`${i18nKey}.errors.400`));
res.status(400).send(
i18n(`${i18nKey}.errors.400`, {
minPort: MIN_PORT_NUMBER,
maxPort: MAX_PORT_NUMBER,
})
);
return;
} else {
const promise = new Promise<{ [instanceId: string]: number }>(
Expand Down
5 changes: 4 additions & 1 deletion utils/detectPort.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ const i18nKey = 'utils.detectPort';

export function detectPort(port?: number | null): Promise<number> {
if (port && (port < MIN_PORT_NUMBER || port > MAX_PORT_NUMBER)) {
throwErrorWithMessage(`${i18nKey}.errors.invalidPort`);
throwErrorWithMessage(`${i18nKey}.errors.invalidPort`, {
minPort: MIN_PORT_NUMBER,
maxPort: MAX_PORT_NUMBER,
});
}

const portToUse = port || 0;
Expand Down

0 comments on commit bd1e9cb

Please sign in to comment.