Add error diagnosis