Throw exception when it occurs and fix logic to print error line

Throw exception so my build process fails whenever the deploy script encounters an error. Also, the error message was corrected to display the error line number.