decorate_err_msg function

Capture error and decorate error message.