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.
minor fix.. forgot to reuse the msg variable

sorry about that.. new to github pull request :)
Merge pull request #30 from shijialee/patch-2

refactor logging for finishWithError