fix #439. Report the right location of the error and add pretty print