Improve RPN solver to handle errors