Skip to content

Commit 2f49b94

Browse files
committed
fix: add try catch for get org list function
1 parent e73fa1d commit 2f49b94

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

messages/package_pushupgrade_schedule.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ Org list file is empty.
4747

4848
Org list file is invalid.
4949

50+
# error.invalid-org-list
51+
52+
Org list has invalid org/orgs.
53+
5054
# examples
5155

5256
sf package pushupgrade schedule --package-version 04txyz --scheduled-start-time "2024-12-06T21:00:00" --org-list upgrade-orgs.csv --target-dev-hub myHub

src/commands/package/pushupgrade/schedule.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,15 @@ async function readOrgListFile(filePath: string): Promise<string[]> {
8686
}
8787

8888
function getOrgListFromInput(orgInput: string): string[] {
89-
if (!orgInput) {
90-
throw new Error('Org input is required');
91-
}
89+
try {
90+
if (!orgInput) {
91+
throw new Error('Org input is required');
92+
}
9293

93-
const orgList = orgInput.split(',').map((org) => org.trim());
94+
const orgList = orgInput.split(',').map((org) => org.trim());
9495

95-
return orgList.filter((org) => org.length > 0);
96+
return orgList.filter((org) => org.length > 0);
97+
} catch (error) {
98+
throw new SfError(messages.getMessage('error.invalid-org-list'), error as string | undefined);
99+
}
96100
}

0 commit comments

Comments
 (0)