Skip to content

Commit 1eae75a

Browse files
committed
Allow speakeasy initialization to fail
1 parent 5c00210 commit 1eae75a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/speakeasy.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,20 @@ import { outputError } from "./error";
33

44
let speakeasyInstance: SpeakeasyClient | null = null;
55

6-
export function init(config: Config): SpeakeasyClient {
6+
export function init(config: Config): SpeakeasyClient | null {
77
if (speakeasyInstance != null) {
88
outputError(
99
"Speakeasy has already been initialized, skipping initialization"
1010
);
1111
return speakeasyInstance;
1212
}
1313

14-
speakeasyInstance = new SpeakeasyClient(config);
14+
try {
15+
speakeasyInstance = new SpeakeasyClient(config);
16+
} catch (err: any) {
17+
outputError(err.message);
18+
return null;
19+
}
1520
return speakeasyInstance;
1621
}
1722

0 commit comments

Comments
 (0)