Skip to content

Commit 2b7e158

Browse files
author
Jayant Krishnamurthy
committed
Improve error message
1 parent d14e733 commit 2b7e158

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/cluster.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,9 @@ const clusterToPythProgramKey: Record<Cluster, string> = {
99

1010
/** Gets the public key of the Pyth program running on the given cluster. */
1111
export function getPythProgramKeyForCluster(cluster: Cluster): PublicKey {
12-
return new PublicKey(clusterToPythProgramKey[cluster]);
12+
if (clusterToPythProgramKey[cluster] !== undefined) {
13+
return new PublicKey(clusterToPythProgramKey[cluster]);
14+
} else {
15+
throw new Error(`Invalid Solana cluster name: ${cluster}. Valid options are: ${JSON.stringify(Object.keys(clusterToPythProgramKey))}`)
16+
}
1317
}

0 commit comments

Comments
 (0)