Closed kubukoz closed 1 year ago
Looking at this PR makes me think we need to change the way SmithyProject is being used inside SmithyTextDocumentService. I feel like the NPEs are coming from the fact that createProject won't set the project
property if the project fails to load, so anywhere else we use project
will just get an NPE, and then we have try-catch everywhere. We should think about what functionality is offered if the SmithyProject fails to load, and maybe split that up somehow so we have more deterministic behavior.
I agree in principle, but that's a bigger change and I wanted to provide users with a little bit more context for troubleshooting in the meantime.
Plus, the try-catch captures more than the NPEs - any kind of IOOBEs, for example. I'm not sure we can get rid of these blocks that easily. It would still be nice to avoid the NPEs, though.
Description of changes:
While fighting some issues in a project not loading (recently seeing some similar to #100), I found that we were discarding some useful information, such as stack traces, which makes it more difficult to debug issues on remote machines (such as my colleagues').
This PR adds more
e.printStackTrace()
in cases where we only printed the exception messages. While this isn't perfect, and it's far from ideal UX when you see potentially duplicate stack traces, I find that in this case more is better than none.Many of the issues I'm seeing anytime something goes wrong in loading a project are NPEs on the
project
field inSmithyTextDocumentService
, so I also marked that as nullable to make it clearer that it's not a safe field to use in all cases. We can amend the usages of that field in future PRs so that they have reasonable fallbacks.Example of what would happen after this change given some issue in
FileCachingCollector
(responsible for things like #100):By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.