Getting “503: Large portfolio is not supported in your current plan” error after adding exceptions

Yes, it’s an error. But no, it’s not something we need to resolve. It’s exactly what we want the users to see.

When we tried out the setup tasks while starting out with Module 7, you would’ve seen the dashboard UI throwing out the entire stack trace in the display, right?

We resolved the issue by handling the exceptions causes when the API limit hits the limit and other cases like for empty response. This was done by re-throwing the original exceptions (be it Runtime or Null Pointer exceptions) with a custom StockQuoteService exception. Due to this, the client (annual-return-app) can now check if the thrown exception is StockQuoteService and if so handle it appropriately as they wish. In this case they choose to display the message “Large portfolio is not supported in your current plan”

Regarding the Python utility, there also we can choose to use a try-catch statement to handle the exceptions suitably

The different in the stack trace once we handle exceptions in our Alphavantage/Tiingoservice classes is this

ie, our clients get more context about the error instead of just a general error like Null Pointer Exception