According to @jlee-r7: "StandardError is only marginally better than Exception." So in order to handle registry_setvaldata exceptions you can get two paths:

* The easy one which is rescuing RuntimeError since probably any Exception raised on registry_setvaldata is going to have as ancestor this one (thanks @jlee-r7 for the trick!).
* The harder but prolly better one which would be to check what exceptions can be raised while calling registry_setvaldata. I did a little of digging and I see Rex::Post::Meterpreter::RequestError already being rescued so I guess you could rescue TimeoutError here and be sure which the result from registry_setvaldata isn't nil. If you want to use this approach, please verify which registry_setvaldata doesn't raise more Exceptions!