refactor logging when finishWithError

The refactor also fix the following problems:

1. log level was missing when logging failure that reaches max_attemps(line 280 before)
2. add error message in logging to get a better idea why it failed( line 290 wasn't logging error before). 

thanks.