From 5002c653d53b7ef21a91f889a17f4f2ab52596d8 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 22 Feb 2021 22:05:53 -0700 Subject: tree-wide: Use %q instead of %v as appropriate in error messages --- cmd_command.go | 10 +++++----- cmd_incommit.go | 4 ++-- types.go | 10 +++++----- util.go | 8 ++++---- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/cmd_command.go b/cmd_command.go index 32292d3..f31860b 100644 --- a/cmd_command.go +++ b/cmd_command.go @@ -100,7 +100,7 @@ func (CmdCommit) fiCmdRead(fir fiReader) (cmd Cmd, err error) { // 'committer' (SP )? SP LT GT SP LF if !strings.HasPrefix(ez.PeekLine(), "committer ") { - ez.Errcheck(errors.Errorf("commit: expected committer command: %v", ez.ReadLine())) + ez.Errcheck(errors.Errorf("commit: expected committer command: %q", ez.ReadLine())) } c.Committer, err = ParseIdent(trimLinePrefix(ez.ReadLine(), "committer ")) ez.Errcheck(err) @@ -189,7 +189,7 @@ func (CmdTag) fiCmdRead(fir fiReader) (cmd Cmd, err error) { // 'from' SP LF if !strings.HasPrefix(ez.PeekLine(), "from ") { - ez.Errcheck(errors.Errorf("tag: expected from command: %v", ez.ReadLine())) + ez.Errcheck(errors.Errorf("tag: expected from command: %q", ez.ReadLine())) } c.CommitIsh = trimLinePrefix(ez.ReadLine(), "from ") @@ -200,7 +200,7 @@ func (CmdTag) fiCmdRead(fir fiReader) (cmd Cmd, err error) { // 'tagger' (SP )? SP LT GT SP LF if !strings.HasPrefix(ez.PeekLine(), "tagger ") { - ez.Errcheck(errors.Errorf("tag: expected tagger command: %v", ez.ReadLine())) + ez.Errcheck(errors.Errorf("tag: expected tagger command: %q", ez.ReadLine())) } c.Tagger, err = ParseIdent(trimLinePrefix(ez.ReadLine(), "tagger ")) ez.Errcheck(err) @@ -333,14 +333,14 @@ func (CmdAlias) fiCmdRead(fir fiReader) (cmd Cmd, err error) { // mark if !strings.HasPrefix(ez.PeekLine(), "mark :") { - ez.Errcheck(errors.Errorf("alias: expected mark command: %v", ez.ReadLine())) + ez.Errcheck(errors.Errorf("alias: expected mark command: %q", ez.ReadLine())) } c.Mark, err = strconv.Atoi(trimLinePrefix(ez.ReadLine(), "mark :")) ez.Errcheck(err) // 'to' SP ") if lt < 0 || str[lt] != '<' { - return ret, errors.Errorf("Missing < in ident string: %v", str) + return ret, errors.Errorf("Missing < in ident string: %q", str) } if lt > 0 { if str[lt-1] != ' ' { - return ret, errors.Errorf("Missing space before < in ident string: %v", str) + return ret, errors.Errorf("Missing space before < in ident string: %q", str) } ret.Name = str[:lt-1] } gt := lt + 1 + strings.IndexAny(str[lt+1:], "<>") if gt < lt+1 || str[gt] != '>' { - return ret, errors.Errorf("Missing > in ident string: %v", str) + return ret, errors.Errorf("Missing > in ident string: %q", str) } if str[gt+1] != ' ' { - return ret, errors.Errorf("Missing space after > in ident string: %v", str) + return ret, errors.Errorf("Missing space after > in ident string: %q", str) } ret.Email = str[lt+1 : gt] strWhen := str[gt+2:] sp := strings.IndexByte(strWhen, ' ') if sp < 0 { - return ret, errors.Errorf("missing time zone in when: %v", str) + return ret, errors.Errorf("missing time zone in when: %q", str) } sec, err := strconv.ParseInt(strWhen[:sp], 10, 64) if err != nil { diff --git a/util.go b/util.go index 4ca60e9..544818e 100644 --- a/util.go +++ b/util.go @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Luke Shumaker +// Copyright (C) 2017, 2021 Luke Shumaker // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by @@ -35,19 +35,19 @@ func trimLinePrefix(line string, prefix string) string { func parse_data(line string) (data string, err error) { nl := strings.IndexByte(line, '\n') if nl < 0 { - return "", errors.Errorf("data: expected newline: %v", data) + return "", errors.Errorf("data: expected newline: %q", data) } head := line[:nl+1] rest := line[nl+1:] if !strings.HasPrefix(head, "data ") { - return "", errors.Errorf("data: could not parse: %v", data) + return "", errors.Errorf("data: could not parse: %q", data) } if strings.HasPrefix(head, "data <<") { // Delimited format delim := trimLinePrefix(head, "data <<") suffix := "\n" + delim + "\n" if !strings.HasSuffix(rest, suffix) { - return "", errors.Errorf("data: did not find suffix: %v", suffix) + return "", errors.Errorf("data: did not find suffix: %q", suffix) } data = strings.TrimSuffix(rest, suffix) } else { -- cgit v1.2.3