git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v3 4/8] t0021/rot13-filter: improve error message

From
Christian Couder <christian.couder@gmail.com>
Date
Nov 10, 2017, 13:21 UTC
Message-ID
<20171110132200.7871-5-chriscool@tuxfamily.org>
In-Reply-To
<20171110132200.7871-1-chriscool@tuxfamily.org>

If there is no new line at the end of something it receives, the packet_txt_read() function die()s, but it's difficult to debug without much context.

Let's give a bit more information when that happens.
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
 t/t0021/rot13-filter.pl | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/t/t0021/rot13-filter.pl b/t/t0021/rot13-filter.pl
index 8bba97af1a..55b6e17034 100644
--- a/t/t0021/rot13-filter.pl
+++ b/t/t0021/rot13-filter.pl
@@ -98,7 +98,8 @@ sub packet_txt_read {
 	if ( $res == -1 or $buf eq '' or $buf =~ s/\n$// ) {
 		return ( $res, $buf );
 	}
-	die "A non-binary line MUST be terminated by an LF.";
+	die "A non-binary line MUST be terminated by an LF.\n"
+	    . "Received: '$buf'";
 }
 
 # Read a text line and check that it is in the form "key=value"
-- 
2.15.0.132.g7ad97d78be
Previous: Christian CouderNext: Christian Couder
Message 5 of 10 in “Create Git/Packet.pm”
  1. 0/8 Create Git/Packet.pmChristian Couder, Nov 10, 2017
  2. 1/8 t0021/rot13-filter: fix list comparisonChristian Couder, Nov 10, 2017
  3. 2/8 t0021/rot13-filter: refactor packet reading functionsChristian Couder, Nov 10, 2017
  4. 3/8 t0021/rot13-filter: improve 'if .. elsif .. else' styleChristian Couder, Nov 10, 2017
  5. 4/8 t0021/rot13-filter: improve error messageChristian Couder, Nov 10, 2017
  6. 5/8 t0021/rot13-filter: add packet_initialize()Christian Couder, Nov 10, 2017
  7. 6/8 t0021/rot13-filter: refactor checking final lfChristian Couder, Nov 10, 2017
  8. 7/8 t0021/rot13-filter: add capability functionsChristian Couder, Nov 10, 2017
  9. 8/8 Add Git/Packet.pm from parts of t0021/rot13-filter.plChristian Couder, Nov 10, 2017
  10. Junio C HamanoNov 10, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.