Added better error logging when command fails

Also reformatted with main.go with gofmt.