@@ -62,35 +62,28 @@ std::optional<LinesOfCode> getCodeLines(const ErrPos & errPos)
62
62
LinesOfCode loc;
63
63
try {
64
64
AutoCloseFD fd = open (errPos.file .c_str (), O_RDONLY | O_CLOEXEC);
65
- if (!fd) {
66
- logError (SysError (" opening file '%1%'" , errPos.file ).info ());
67
- return std::nullopt;
68
- }
69
- else
65
+ if (!fd) return {};
66
+
67
+ // count the newlines.
68
+ int count = 0 ;
69
+ string line;
70
+ int pl = errPos.line - 1 ;
71
+ do
70
72
{
71
- // count the newlines.
72
- int count = 0 ;
73
- string line;
74
- int pl = errPos.line - 1 ;
75
- do
76
- {
77
- line = readLine (fd.get ());
78
- ++count;
79
- if (count < pl)
80
- {
81
- ;
82
- }
83
- else if (count == pl) {
84
- loc.prevLineOfCode = line;
85
- } else if (count == pl + 1 ) {
86
- loc.errLineOfCode = line;
87
- } else if (count == pl + 2 ) {
88
- loc.nextLineOfCode = line;
89
- break ;
90
- }
91
- } while (true );
92
- return loc;
93
- }
73
+ line = readLine (fd.get ());
74
+ ++count;
75
+ if (count < pl)
76
+ ;
77
+ else if (count == pl)
78
+ loc.prevLineOfCode = line;
79
+ else if (count == pl + 1 )
80
+ loc.errLineOfCode = line;
81
+ else if (count == pl + 2 ) {
82
+ loc.nextLineOfCode = line;
83
+ break ;
84
+ }
85
+ } while (true );
86
+ return loc;
94
87
}
95
88
catch (EndOfFile & eof) {
96
89
if (loc.errLineOfCode .has_value ())
@@ -99,7 +92,6 @@ std::optional<LinesOfCode> getCodeLines(const ErrPos & errPos)
99
92
return std::nullopt;
100
93
}
101
94
catch (std::exception & e) {
102
- printError (" error reading nix file: %s\n %s" , errPos.file , e.what ());
103
95
return std::nullopt;
104
96
}
105
97
} else {
0 commit comments