It seems there should be more strict type checking for arguments in SparkR APIs. This was discussed in several PRs.
Roughly it seems there are three cases as below:
The first case below was described in https://github.com/apache/spark/pull/15239#discussion_r82445435
- Check for zero-length variable name
Some of other cases below were handled in https://github.com/apache/spark/pull/15231#discussion_r80417904
- Catch the exception from JVM and format it as pretty
- Check strictly types before calling JVM in SparkR