Skip to content

Commit

Permalink
querylog: improve error reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
ainar-g committed Nov 19, 2020
1 parent 807b23a commit bbdeabb
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions internal/querylog/qlog_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func (q *QLogFile) Seek(timestamp int64) (int64, int, error) {
// If we're testing the same line twice then most likely
// the scope is too narrow and we won't find anything
// anymore in any other file.
return 0, depth, fmt.Errorf("couldn't find timestamp %v: %w", timestamp, ErrTSNotFound)
return 0, depth, fmt.Errorf("looking up timestamp %d in %q: %w", timestamp, q.file.Name(), ErrTSNotFound)
} else if lineIdx == fileInfo.Size() {
return 0, depth, ErrTSTooLate
}
Expand All @@ -122,9 +122,8 @@ func (q *QLogFile) Seek(timestamp int64) (int64, int, error) {

// Get the timestamp from the query log record
ts := readQLogTimestamp(line)

if ts == 0 {
return 0, depth, fmt.Errorf("couldn't get timestamp: %w", ErrTSNotFound)
return 0, depth, fmt.Errorf("looking up timestamp %d in %q: record %q has empty timestamp", timestamp, q.file.Name(), line)
}

if ts == timestamp {
Expand All @@ -146,7 +145,7 @@ func (q *QLogFile) Seek(timestamp int64) (int64, int, error) {

depth++
if depth >= 100 {
return 0, depth, fmt.Errorf("seek depth is too high, aborting. File %s, timestamp %v: %w", q.file.Name(), timestamp, ErrTSNotFound)
return 0, depth, fmt.Errorf("looking up timestamp %d in %q: depth %d too high: %w", timestamp, q.file.Name(), depth, ErrTSNotFound)
}
}

Expand Down

0 comments on commit bbdeabb

Please sign in to comment.