brbzull0 commented on code in PR #10112:
URL: https://github.com/apache/trafficserver/pull/10112#discussion_r1279412511
##########
mgmt/rpc/jsonrpc/json/YAMLCodec.h:
##########
@@ -174,41 +174,31 @@ class yamlcpp_json_encoder
{
///
/// @brief Function to encode an error.
- /// Error could be from two sources, presence of @c std::error_code means a
high level and the @c ts::Errata a callee . Both will
- /// be written into the passed @c out YAML::Emitter. This is mainly a
convenience class for the other two encode_* functions.
+ /// Error could be from two sources, presence of @c std::error_code means a
high level and the @c swoc::Errata a callee . Both
+ /// will be written into the passed @c out YAML::Emitter. This is mainly a
convenience class for the other two encode_* functions.
///
/// @param error std::error_code High level, main error.
/// @param errata the Errata from the callee
/// @param json output parameter. YAML::Emitter.
///
static void
- encode_error(std::error_code error, ts::Errata const &errata, YAML::Emitter
&json)
+ encode_error(swoc::Errata const &errata, YAML::Emitter &json)
{
json << YAML::Key << "error";
json << YAML::BeginMap;
- json << YAML::Key << "code" << YAML::Value << error.value();
- json << YAML::Key << "message" << YAML::Value << error.message();
- if (!errata.isOK()) {
+ json << YAML::Key << "code" << YAML::Value << errata.code().value();
+ json << YAML::Key << "message" << YAML::Value << errata.code().message();
+ if (!errata.is_ok()) {
json << YAML::Key << "data";
json << YAML::BeginSeq;
for (auto const &err : errata) {
- json << YAML::BeginMap;
- json << YAML::Key << "code" << YAML::Value << err.getCode();
- json << YAML::Key << "message" << YAML::Value << err.text();
- json << YAML::EndMap;
+ json << YAML::Value << std::string(err.text()); // FIXME!! Shouldn't
need a @c std::string
Review Comment:
The [data](https://www.jsonrpc.org/specification#error_object) is user
defined information for the specific higher error, we use this structure to
show inner error of an operation, like :
```json
{
"jsonrpc": "2.0",
"id": "msg001",
"error": {
"code": 9,
"message": "Error during execution",
"data": [{
"code": 3000,
"message": "Server already draining."
}]
}
}
```
We can include the severity inside each inner error object.
```json
"data": [{
"code": 3000,
"severity": "Fatal"
"message": "Server already draining."
}]
```
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]