When partially signing a transaction using signrawtransaction, if the wallet doesn't have access to a key, it will output a scary error message "error": "Operation not valid with the current stack size", yet it will partially sign the transaction anyway. This puts a lot of users off, because they don't realise the signing actually succeeded for some inputs. This catches that specific error when signing, and outputs a friendlier message which says Unable to sign input, invalid stack size (possibly missing key).
This is the best way I could think of to fix the issue, but please let me know if you come up with a better way to do it :)