You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@trafficserver.apache.org by GitBox <gi...@apache.org> on 2022/05/16 14:49:38 UTC

[GitHub] [trafficserver] brbzull0 opened a new pull request, #8852: traffic_ctl - JSONRPC: make sure we display the error regardless of the formatting type.

brbzull0 opened a new pull request, #8852:
URL: https://github.com/apache/trafficserver/pull/8852

   While working on a different pr I found out that some error weren't displayed by `traffic_ctl` as it was before the jsonrpc change, this change fixes this and also changes the output style for a "better" quick read, more like it was before jsonrpc.
   
   Now this prints the main error and in a second level the more specifics. There could be more than one second level error.
   ```
   $ traffic_ctl config set invalid.record val
   Server Error found:
   [9] Error during execution
   - [2000] Record not found.
   ```


-- 
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: github-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [trafficserver] brbzull0 commented on pull request #8852: traffic_ctl - JSONRPC: make sure we display the error regardless of the formatting type.

Posted by GitBox <gi...@apache.org>.
brbzull0 commented on PR #8852:
URL: https://github.com/apache/trafficserver/pull/8852#issuecomment-1128725153

   > What happened to pretty printing? Is that always the case now?
   
   No, it still work for  cases  that it's implemented and you request it, but the pretty printing is more for message ouitput(`jsonrpc.result`) and not for the error. This is for  general error, so it will be printed anyway  regardless your `--format` choice.


-- 
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: github-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [trafficserver] brbzull0 merged pull request #8852: traffic_ctl - JSONRPC: make sure we display the error regardless of the formatting type.

Posted by GitBox <gi...@apache.org>.
brbzull0 merged PR #8852:
URL: https://github.com/apache/trafficserver/pull/8852


-- 
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: github-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [trafficserver] cmcfarlen commented on a diff in pull request #8852: traffic_ctl - JSONRPC: make sure we display the error regardless of the formatting type.

Posted by GitBox <gi...@apache.org>.
cmcfarlen commented on code in PR #8852:
URL: https://github.com/apache/trafficserver/pull/8852#discussion_r874225736


##########
include/shared/rpc/RPCRequests.h:
##########
@@ -203,23 +203,15 @@ operator<<(std::ostream &os, const RecordLookUpResponse::RecordError &re)
 inline std::ostream &
 operator<<(std::ostream &os, const JSONRPCError &err)
 {
-  os << "Error found.\n";
-  os << "code: " << err.code << '\n';
-  os << "message: " << err.message << '\n';
+  os << "Server Error found:\n";
+  os << "[" << err.code << "] " << err.message << '\n';
   if (err.data.size() > 0) {
-    os << "---\nAdditional error information found:\n";
-    auto my_print = [&](auto const &e) {
-      os << "+ code: " << e.first << '\n';
-      os << "+ message: " << e.second << '\n';
-    };
-
     auto iter = std::begin(err.data);
 
-    my_print(*iter);
+    os << "- [" << iter->first << "] " << iter->second << '\n';
     ++iter;
     for (; iter != std::end(err.data); ++iter) {
-      os << "---\n";
-      my_print(*iter);
+      os << "- [" << iter->first << "] " << iter->second << '\n';

Review Comment:
   Since the interleaved `---` is no longer being printed, this could just be a simple `for (auto it: err.data) ...` loop.



-- 
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: github-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [trafficserver] brbzull0 commented on a diff in pull request #8852: traffic_ctl - JSONRPC: make sure we display the error regardless of the formatting type.

Posted by GitBox <gi...@apache.org>.
brbzull0 commented on code in PR #8852:
URL: https://github.com/apache/trafficserver/pull/8852#discussion_r874673363


##########
include/shared/rpc/RPCRequests.h:
##########
@@ -203,23 +203,15 @@ operator<<(std::ostream &os, const RecordLookUpResponse::RecordError &re)
 inline std::ostream &
 operator<<(std::ostream &os, const JSONRPCError &err)
 {
-  os << "Error found.\n";
-  os << "code: " << err.code << '\n';
-  os << "message: " << err.message << '\n';
+  os << "Server Error found:\n";
+  os << "[" << err.code << "] " << err.message << '\n';
   if (err.data.size() > 0) {
-    os << "---\nAdditional error information found:\n";
-    auto my_print = [&](auto const &e) {
-      os << "+ code: " << e.first << '\n';
-      os << "+ message: " << e.second << '\n';
-    };
-
     auto iter = std::begin(err.data);
 
-    my_print(*iter);
+    os << "- [" << iter->first << "] " << iter->second << '\n';
     ++iter;
     for (; iter != std::end(err.data); ++iter) {
-      os << "---\n";
-      my_print(*iter);
+      os << "- [" << iter->first << "] " << iter->second << '\n';

Review Comment:
   True.  Missed that, thanks a lot, fixed now.



-- 
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: github-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org