235 parseVCppCompilerCLLine(line, currentProjectPath.toAbsolutePath().toString(), fileElement);
236 } catch (InvalidPathException e) {
237 LOG.warn("Cannot extract information from current element: {} - {}", data, e.getMessage());
238 } catch (NullPointerException e) {239 LOG.error("Bug in parser, please report: '{}' - '{}'", data + " @ " + currentProjectPath, e);
240 }
241 }
This code appears to catch a NullPointerException
. This may hide bad errors in code.
Consider removing the offending clause and debugging the underlying cause of the exception instead.
When an NPE is caught solely so it can be silenced, it can indicate that the underlying cause of the exception is not properly known. If an NPE is thrown, it may be that the application is in an inconsistent state which should not be ignored.
try {
// ...
} catch (NullPointerException n) { // Debug the cause instead!
n.printStackTrace();
}
Remove the catch clause that handles NullPointerException
and debug the underlying issue instead.
If the reason for throwing NPEs is within library code or within code that you have no control over, it may not be possible to easily fix the issue. In such cases, consider ignoring this issue with a skipcq
comment above the offending line.
// skipcq
somethingThatThrows();