HTTP Accept-Encoding: br; Added brotli errors codes

This commit is contained in:
Mikhail Fandyushin 2019-03-27 00:32:29 +03:00
parent 4b7ac9e9b4
commit c53b303bc2
5 changed files with 18 additions and 5 deletions

View File

@ -420,6 +420,8 @@ namespace ErrorCodes
extern const int NO_COMMON_COLUMNS_WITH_PROTOBUF_SCHEMA = 443;
extern const int UNKNOWN_PROTOBUF_FORMAT = 444;
extern const int CANNOT_MPROTECT = 445;
extern const int BROTLI_READ_FAILED = 446;
extern const int BROTLI_WRITE_FAILED = 447;
extern const int KEEPER_EXCEPTION = 999;
extern const int POCO_EXCEPTION = 1000;

View File

@ -56,7 +56,7 @@ bool BrotliReadBuffer::nextImpl()
if (brotli->result == BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT && (!in_available || in.eof()))
{
throw Exception(std::string("brotli decode error"), ErrorCodes::CANNOT_READ_ALL_DATA);
throw Exception(std::string("brotli decode error"), ErrorCodes::BROTLI_READ_FAILED);
}
out_capacity = internal_buffer.size();
@ -76,13 +76,13 @@ bool BrotliReadBuffer::nextImpl()
}
else
{
throw Exception(std::string("brotli decode error"), ErrorCodes::CANNOT_READ_ALL_DATA);
throw Exception(std::string("brotli decode error"), ErrorCodes::BROTLI_READ_FAILED);
}
}
if (brotli->result == BROTLI_DECODER_RESULT_ERROR)
{
throw Exception(std::string("brotli decode error"), ErrorCodes::CANNOT_READ_ALL_DATA);
throw Exception(std::string("brotli decode error"), ErrorCodes::BROTLI_READ_FAILED);
}
return true;

View File

@ -7,6 +7,11 @@
namespace DB
{
namespace ErrorCodes
{
extern const int BROTLI_READ_FAILED;
}
class BrotliReadBuffer : public BufferWithOwnMemory<ReadBuffer>
{
public:

View File

@ -72,7 +72,7 @@ void BrotliWriteBuffer::nextImpl()
if (result == 0)
{
throw Exception(std::string("brotli compress failed: "), ErrorCodes::CANNOT_WRITE_AFTER_END_OF_BUFFER);
throw Exception(std::string("brotli compress failed"), ErrorCodes::BROTLI_WRITE_FAILED);
}
}
while (in_available > 0 || out_capacity == 0);
@ -110,7 +110,7 @@ void BrotliWriteBuffer::finish()
if (result == 0)
{
throw Exception(std::string("brotli compress failed: "), ErrorCodes::CANNOT_WRITE_AFTER_END_OF_BUFFER);
throw Exception(std::string("brotli compress failed"), ErrorCodes::BROTLI_WRITE_FAILED);
}
}
}

View File

@ -5,6 +5,12 @@
namespace DB
{
namespace ErrorCodes
{
extern const int BROTLI_WRITE_FAILED;
}
class BrotliWriteBuffer : public BufferWithOwnMemory<WriteBuffer>
{
public: