nylas-java
nylas-java copied to clipboard
Need to access Response Headers through RequestFailedException
Is your feature request related to a problem? Please describe. When performing email account authorization with Nylas, if the request fails due to hitting the rate limit (status code 429), Nylas suggests implementing an exponential backoff strategy. However, the RequestFailedException thrown by Nylas does not provide access to the response headers, which contain valuable information such as the rate limit and reset time.
Describe the solution you'd like
- Modify the executeRequest method in the NylasClient class to capture and return the response headers along with the response body.
- Enhance the RequestFailedException class to include a field for storing the response headers.
- Pass the response headers to the RequestFailedException.parseErrorResponse method when creating a new instance of RequestFailedException.
- Provide getter methods in the RequestFailedException class to retrieve the response headers.
- Then we can utilize the response headers in the application code to implement the exponential backoff strategy based on the rate limit and reset time provided by Nylas.
Thanks for opening this issue @rknikode, we will look into this and see if we can put these improvements on a roadmap. We will reply here when we have an update.