Bklyn opened a new issue #7787:
URL: https://github.com/apache/pulsar/issues/7787


   **Is your enhancement request related to a problem? Please describe.**
   The Pulsar C++ client library throws `const char*` in several locations 
instead of `std::exception` or a derived type.
   
   **Describe the solution you'd like**
   Throw `std::exception` or some derived type instead.
   
   **Describe alternatives you've considered**
   If you're going to throw something, `std::exception` is the expected type in 
modern C++
   
   **Details**
   ```c++
   /lib/MessageBuilder.cc:112:        throw "sequenceId needs to be >= 0";
   ./lib/CompressionCodecSnappy.cc:59:    throw "Snappy compression not 
supported";
   ./lib/CompressionCodecSnappy.cc:64:    throw "Snappy compression not 
supported";
   ./lib/ProducerConfiguration.cc:70:        throw "maxPendingMessages needs to 
be greater than 0";
   ./lib/ProducerConfiguration.cc:80:        throw "maxPendingMessages needs to 
be greater than 0";
   ./lib/ProducerConfiguration.cc:134:        throw "batchingMaxMessages needs 
to be greater than 1";
   ./lib/ConsumerConfiguration.cc:96:        throw "Consumer Config Exception: 
Unacknowledged message timeout should be greater than 10 seconds.";
   ./lib/auth/AuthOauth2.cc:105:        throw "ExpiresIn in Oauth2TokenResult 
invalid value: " + expiredIn;
   ./lib/auth/AuthToken.cc:55:        throw "Failed to read environment 
variable " + envVarName;
   ./lib/auth/AuthToken.cc:77:        throw "Invalid configuration for token 
provider";
   ./lib/MessageId.cc:79:        throw "Failed to parse serialized message id";
   ./lib/CompressionCodecZstd.cc:61:SharedBuffer 
CompressionCodecZstd::encode(const SharedBuffer& raw) { throw "ZStd compression 
not supported"; }
   ./lib/CompressionCodecZstd.cc:65:    throw "ZStd compression not supported";
   ```
   Invalid arguments or bad config (i.e. `sequenceId needs to be >= 0`) should 
result in `std::invalid_argument`.  The `not supported` exceptions should 
perhaps be `runtime_error` or maybe just bare `exception`s.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to