How to handle The actor or task with ID … cannot be scheduled right now

I see this error quite a few times and I generally manage to solve it providing enough memory as I have a predefined set of actors/deployments which I know upfront, but my issue is that I’d like to get somehow this error and do something, like let the app crash or something else, but this message is just appearing in the logs and I cannot see how to capture this event. I might want to stop the execution of what I’m doing and return 500 to the user (for example), or notify us via slack. I cannot do this, however, cause I cannot see any way to capture this message or an event/error.
Any idea about how to solve my issue?
P.S. (The autoscaler won;t solve my issue cause I might want to run this locally on my machine to test the code, or I might not want to schedule new nodes after some point)