Adding better error messages when converting to Java string