[MNG-5613] fix NullPointerException when error occur during project dependency graph creation

Same as [this pull request](https://github.com/apache/maven/pull/12) but with unit tests.