google-cloud-cpp: Sample code and quickstarts should print full errors
Our sample/quickstart code only prints the error message, discarding the error code and error info. They look something like this (in the StatusOr<>
case):
https://github.com/googleapis/google-cloud-cpp/blob/08f1d4a76d92d79c8a5200a3c13e4453e8ad29a4/google/cloud/accessapproval/quickstart/quickstart.cc#L31
Printing the full error gives customers more information to debug issues they might encounter. Our sample/quickstart code should reflect the code we want our customers to write.
We can just make this public: https://github.com/googleapis/google-cloud-cpp/blob/08f1d4a76d92d79c8a5200a3c13e4453e8ad29a4/google/cloud/status.cc#L22-L26 … and do a tedious find and replace.
- Fix
examples/
- Fix
google/cloud/bigquery/samples/
- Fix
google/cloud/iam/samples/
- Fix
google/cloud/pubsub/samples/
- Fix
google/cloud/bigtable/examples/
- Fix
google/cloud/storage/examples/
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 15 (8 by maintainers)
Commits related to this issue
- cleanup(spanner): throw full Status values Throw `google::cloud::Status` values directly in samples, instead of wrapping only their messages in a `std::runtime_error`. And then tweak to avoid `misc-... — committed to devbww/google-cloud-cpp by devbww 2 years ago
- cleanup(spanner): throw full Status values (#9892) Throw `google::cloud::Status` values directly in samples, instead of wrapping only their messages in a `std::runtime_error`. And then tweak to av... — committed to googleapis/google-cloud-cpp by devbww 2 years ago
How about throwing the whole
Status
value, and then just streaming it when caught?