Remove trailing whitespace and modify onCreateError