@@ -158,12 +158,27 @@ except RateLimitError as error:
158158except TimeoutError :
159159 print (" Retry once, then check https://status.oilpriceapi.com." )
160160except OilPriceAPIError as error:
161+ # Safe support context: do not log your API key or request headers.
162+ if error.request_id:
163+ print (" Support request ID:" , error.request_id)
161164 if error.status_code in (402 , 403 ):
162- print (" Review dataset access for this account." )
165+ print (
166+ " Review dataset access for this account." ,
167+ error.required_plan,
168+ error.required_feature,
169+ error.remediation_url,
170+ )
163171 else :
164172 raise
165173```
166174
175+ All non-2xx responses share the same ` OilPriceAPIError ` attributes, including
176+ ` status_code ` , ` code ` , ` request_id ` , plan/feature recovery fields, retry
177+ metadata, sanitized response ` headers ` , ` raw_body ` , and ` raw_text ` . Canonical
178+ nested and legacy flat API error envelopes are normalized into that contract.
179+ Transport failures use ` NetworkError ` ; timeouts remain the more specific
180+ ` TimeoutError ` .
181+
167182Executable recovery examples cover 401, 403, 429, and timeout responses under
168183[ ` examples/snippets/ ` ] ( examples/snippets/ ) . Empty or malformed successful
169184responses should stop analysis rather than inventing a price, unit, currency,
0 commit comments