Skip to content

Commit ce9b46c

Browse files
committed
better error handling in example usage
1 parent f916b08 commit ce9b46c

1 file changed

Lines changed: 13 additions & 11 deletions

File tree

gusto_embedded/README.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ Generally, the SDK will work well with most IDEs out of the box. However, when u
106106
- [PyCharm Pydantic Plugin](https://docs.pydantic.dev/latest/integrations/pycharm/)
107107
<!-- End IDE Support [idesupport] -->
108108

109-
<!-- Start SDK Example Usage [usage] -->
109+
<!-- No SDK Example Usage [usage] -->
110110
## SDK Example Usage
111111

112112
### Example
@@ -116,10 +116,11 @@ Generally, the SDK will work well with most IDEs out of the box. However, when u
116116
from gusto_embedded import Gusto
117117
import os
118118

119-
with Gusto(
120-
company_access_auth=os.getenv("GUSTO_COMPANY_ACCESS_AUTH", ""),
121-
) as gusto:
119+
auth_token = os.getenv("GUSTO_COMPANY_ACCESS_AUTH", None)
120+
if auth_token is None:
121+
raise ValueError("GUSTO_COMPANY_ACCESS_AUTH is not set")
122122

123+
with Gusto(company_access_auth=auth_token) as gusto:
123124
res = gusto.introspection.get_info()
124125

125126
# Handle response
@@ -136,18 +137,19 @@ from gusto_embedded import Gusto
136137
import os
137138

138139
async def main():
139-
async with Gusto(
140-
company_access_auth=os.getenv("GUSTO_COMPANY_ACCESS_AUTH", ""),
141-
) as gusto:
140+
auth_token = os.getenv("GUSTO_COMPANY_ACCESS_AUTH", None)
141+
if auth_token is None:
142+
raise ValueError("GUSTO_COMPANY_ACCESS_AUTH is not set")
142143

143-
res = await gusto.introspection.get_info_async()
144+
async with Gusto(company_access_auth=auth_token) as gusto:
145+
res = gusto.introspection.get_info_async()
144146

145-
# Handle response
146-
print(res)
147+
# Handle response
148+
print(res)
147149

148150
asyncio.run(main())
149151
```
150-
<!-- End SDK Example Usage [usage] -->
152+
<!-- No SDK Example Usage [usage] -->
151153

152154
<!-- Start Authentication [security] -->
153155
## Authentication

0 commit comments

Comments
 (0)