Skip to content

Commit

Permalink
Make irc2json print an error on stderr if something fails
Browse files Browse the repository at this point in the history
  • Loading branch information
Mm2PL committed Jan 27, 2023
1 parent df2b173 commit df701a3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion cmd/irc2json/irc2json.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ func main() {
scanner := bufio.NewScanner(os.Stdin)
encoder := json.NewEncoder(os.Stdout)

i := 0
for scanner.Scan() {
i += 1
msg, err := justgrep.NewMessage(scanner.Text())
if err != nil {
_, _ = fmt.Fprintf(os.Stderr, "Failed to irc parse message: %s\n", err)
_, _ = fmt.Fprintf(os.Stderr, "Line %d: Failed to irc parse message: %s\n", i, err)
os.Exit(1)
}
err = encoder.Encode(msg)
Expand Down

0 comments on commit df701a3

Please sign in to comment.