@@ -133,11 +133,19 @@ response = await agent.run("Tell me about quantum computing")
133133
134134### Error Handling
135135
136+ The package provides custom exceptions for Nova-specific errors, along with support for Strands SDK exceptions:
137+
136138``` python
137139from strands.types.exceptions import (
138140 ContextWindowOverflowException,
139141 ModelThrottledException
140142)
143+ from strands_nova import (
144+ NovaAPIException, # Base exception for all Nova API errors
145+ NovaValidationException, # HTTP 400 validation errors
146+ NovaModelNotFoundException, # HTTP 404 model not found
147+ NovaModelException # HTTP 500 internal model errors
148+ )
141149
142150try :
143151 async for chunk in model.stream(messages = messages):
@@ -149,10 +157,32 @@ except ContextWindowOverflowException as e:
149157except ModelThrottledException as e:
150158 print (f " Rate limited: { e} " )
151159 # Implement retry with backoff
160+ except NovaValidationException as e:
161+ print (f " Validation error: { e} " )
162+ # Check request parameters
163+ except NovaModelNotFoundException as e:
164+ print (f " Model not found: { e} " )
165+ # Verify model_id is correct
166+ except NovaModelException as e:
167+ print (f " Model error: { e} " )
168+ # Nova API internal error
169+ except NovaAPIException as e:
170+ print (f " Nova API error: { e} " )
171+ # Catch-all for other Nova errors
152172except Exception as e:
153- print (f " API error: { e} " )
173+ print (f " Unexpected error: { e} " )
154174```
155175
176+ ** Custom Nova Exceptions:**
177+ - ` NovaAPIException ` : Base exception for all Nova API errors
178+ - ` NovaValidationException ` : Raised for HTTP 400 validation errors (malformed requests, invalid parameters)
179+ - ` NovaModelNotFoundException ` : Raised for HTTP 404 errors (model not found or inaccessible)
180+ - ` NovaModelException ` : Raised for HTTP 500 errors (internal model service errors)
181+
182+ ** Strands SDK Exceptions:**
183+ - ` ContextWindowOverflowException ` : Raised when input exceeds the model's context window
184+ - ` ModelThrottledException ` : Raised when requests are rate-limited (HTTP 429)
185+
156186## Getting Your API Key
157187
1581881 . Visit [ https://nova.amazon.com/dev-apis ] ( https://nova.amazon.com/dev-apis )
0 commit comments