Show more detail in log on brotli errors (eustas)

This commit is contained in:
Joshua Marantz
2016-05-18 08:47:14 -04:00
parent faaf624ff9
commit 985bb49b2b
2 changed files with 6 additions and 2 deletions
+5 -1
View File
@@ -108,8 +108,12 @@ bool BrotliInflater::DecompressHelper(StringPiece in, MessageHandler* handler,
// Decompression succeeded, write out the last chunk if needed.
break;
case BROTLI_RESULT_ERROR:
// TODO(eustas): use brotli API to convert error code to string.
#ifdef BROTLI_ERROR_CODES_LIST
handler->Message(kError, "%s",
BrotliErrorString(BrotliGetErrorCode(brotli_state_.get())));
#else
handler->Message(kError, "BROTLI_RESULT_ERROR");
#endif
return false;
}
StringPiece chunk(output, sizeof(output) - available_out);
@@ -82,7 +82,7 @@ TEST(BrotliInflater, TestCorruptInputBrotliDecompress) {
StringPiece compressed(kHelloBrotliCorrupt, sizeof(kHelloBrotliCorrupt));
EXPECT_FALSE(
BrotliInflater::Decompress(compressed, &handler, &decompress_writer));
EXPECT_STREQ("Error: BROTLI_RESULT_ERROR", handler.messages()[0]);
EXPECT_TRUE(HasPrefixString(handler.messages()[0], "Error: BROTLI_"));
}
TEST(BrotliInflater, TestTruncatedInputBrotliDecompress) {